SP8409 FAVSUBS - Favorite Sub Hair

Description

![](http://farm5.static.flickr.com/4101/5433129276_143f85ce44.jpg) Little Princess Rapunzel is blessed with long (really looong!) hair, which is golden colored and has healing power. After the end of a long happy story, she marries her lover Flynn. They decide to lead a normal life by getting rid of the mysterious hair, which when cut loses its power and turns brown. There are many colorful beads on her hair in order. Rapunzel has some **K** favorite colors **B**\[1...K\] To remember good old stories, she wants to keep a part of her hair after its cut. A favorite sub hair is that continuous part of the hair, which has each of her favorite color beads at least once. For the purpose of this problem, we represent a color as an integer and Hair as an array **A**\[1...N\], which has exactly **N** colored beads in the given order. Could you please tell her the total number of ways she can cut her favorite sub hair (sub-array). Two sub-arrays are different, if their starting or ending index in A differ.

Input Format

First line contains T \[ number of test cases, around 10 \]. Each test case is preceded by a blank line, including the 1st case. \[ -2,000,000

Output Format

For each test case, output the number of different sub-arrays, which has her favorite color appearing at least once, in a separate line.