Password security is a tricky problem. Users prefer short and simple passwords that are easy to remember, but those passwords are not safe enough, so an environment with stronger security imposes a password policy. Here is one example of a password policy for a user account in a domain.
The password must be at least six characters long, and it must contain at least one character from each of the following categories.
You are given a string of letters and digits. Find the length of the shortest contiguous substring of that string that satisfies the password policy above.
The input contains N test cases. The first line has one integer N (1≤N≤50).
Each of the next N lines holds one test case, a string of at most 200 letters and digits.
Print the result of the i-th test case on the i-th line. Print one integer, the minimum length of a contiguous substring that satisfies the password policy. If no such substring exists, print 0.