You work in a leading software development company. As you are great in coding, most of the critical tasks are allotted for you. You like the challenge and you feel excited to solve those problems.
Recently your company is developing a project named Document Analyzer. In this project you are assigned a task; of course a critical task. The task is that you are given a document consisting of lowercase letters, numbers and punctuations. You have to analyze the document and separate the words first. Words are consecutive sequences of lower case letters. After listing the words, in the order same as they occurred in the document, you have to number them from 1, 2, ..., n. After that you have to find the range p and q (p ≤ q) such that all kinds of words occur between p and q (inclusive). If there are multiple such solutions you have to find the one where the difference of p and q is smallest. If still there is a tie, then find the solution where p is smallest.
Input
Input starts with an integer T (≤ 15), denoting the number of test cases.
Each case will be denoted by one or more lines denoting a document. Each line contains no more than 100 characters. A document will contain either lowercase letters or numbers or punctuations. The last line of a document will contain the word 'END' which is of course not the part of the document. You can assume that a document will contain between 1 and 50000 words (inclusive). Words may contain up to 10 characters. And a document can contain up to 5000 lines.
Output
For each case, print the case number and p and q as described above.
Sample
Sample Input | Sample Output |
---|---|
3 1. a case is a case, 2. case is not a case~ END a b c d e END a@#$a^%a a a b b----b b++12b END | Case 1: 6 9 Case 2: 1 5 Case 3: 5 6 |
Notes
Dataset is huge, use faster I/O methods.