TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Password security is a tricky issue. Users usually prefer short and simple passwords that are easy to remember, but such passwords are not secure enough. So, there should be some password policy requirements in security-enhanced
environments. Below is an example of a password policy requirement for a user account in a domain:



The password should be at least six characters in length and should contain characters from all the following categories:

1) English uppercase letters (A through Z)

2) English lowercase letters (a through z)

3) Base 10 digits (0 through 9)




Given a string of alphanumeric (lower case, upper case, or digit) characters, your task is to find the length of its shortest contiguous substring which satisfies the above password policy requirement stated.

Input Format

The input contains N test cases. The first line of the input has one integer N (1<=N<=50).
Each of the next N lines is a test case having a string of at most 20000 alphanumeric characters.

Output Format

Write the result of the i-th test case, on the i-th line of output. You should just write one integer indicating the minimum length of a contiguous substring which satisfies the password policy. If there is no such substring, write "0".

Sample Input 1

4
AliKam123test
AbCdEfG
88syadneerG
Windows7released21october2009

Sample Output 1

6
0
10
8

Hints

Problem Source

Migrated from old NTUJ.

2009Tehran

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 200