Hamza
InterviewTime limit1sMemory limit256 MB
Find the shortest prefix of the category list that contains every distinct category appearing in the whole list.
Problem
Hamza and his coach decided to practice on an online judge. The judge lists problems, and every problem belongs to exactly one category.
Hamza solves the problems in the order they are listed. He never solves problem before problem , because he and his coach agreed that going in order trains him on every problem, even one that is awkward to implement. His goal is to solve at least one problem from every category that exists on the judge.
You are given the category of every problem in listing order. Determine how many problems Hamza solves, counting from the first one, until he has solved at least one problem in every category on the judge.
Input
The first line contains , the number of test cases ().
Each test case takes two lines. The first line contains , the number of problems on the judge (). The second line contains integers separated by single spaces, giving the category number of each problem from the first one to the last one. Every category number is between and .
Output
For each test case, print one line in the form Case n: R, where is the test case number starting from 1 and is the smallest number of problems Hamza solves from the beginning so that he has solved at least one problem in every category that appears on the judge.