There are players standing in a row each player has a digit written on their T-Shirt (multiple players can have the same number written on their T-Shirt).   
You have to select a group of players, note that players in this group should be standing in $\textbf{consecutive fashion}$. For example second player of chosen group next to first player of chosen group, third player next to second and similarly last player next to second last player of chosen group. Basically You've to choose a contiguous group of players.
After choosing a group, players can be paired if they have the same T-Shirt number (one player can be present in at most one pair), finally the chosen group is called “good” if at most one player is left unmatched. Your task is to find the size of the maximum “good” group.
Formally, you are given a string $S=s_{1}s_{2}s_{3}...s_{i}...s_{n}$ where $s_{i}$ can be any digit character between $'0'$ and $'9'$ and $s_{i}$ denotes the number written on the T-Shirt of $i^{th}$ player. Find a value $length$ such that there exist pair of indices $(i,j)$ which denotes $S[i...j]$ is a “good” group where $i\geq1$ and $j\leq S.length$ and $i\leq j$ and $(j-i+1)=length$ and there exist no other pair $(i’,j’)$ such that $(j’-i’+1)>length$ and $S[i'...j']$ is a "good" group.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- $i^{th}$ testcase consist of a single line of input, a string $S$. 

-----Output:-----
For each testcase, output in a single line maximum possible size of a "good" group.

-----Constraints-----
$\textbf{Subtask 1} (20 points)$
- $1 \leq T \leq 10$
- $S.length \leq 10^{3}$
$\textbf{Subtask 2} (80 points)$
- $1 \leq T \leq 10$
- $S.length \leq 10^{5}$

-----Sample Input:-----
1

123343

-----Sample Output:-----
3

-----EXPLANATION:-----
1$\textbf{$\underline{2 3 3}$}$43
Underlined group is a “good” group because the second player(number 2 on T-Shirt) is the only player who is left unmatched and third and fourth player can form a pair, no other group has length greater than 3 that are “good”. However note that we have other “good” group also 12$\textbf{$\underline{334}$}$3 but length is 3 which is same as our answer.

-----Sample Input:-----
1

95665

-----Sample Output:-----
5

-----EXPLANATION:-----
$\textbf{$\underline{95665}$}$ is “good” group because first player is the only player who is left unmatched second and fifth player can form pair and third and fourth player also form pair.

-----Sample Input:-----
2

2323

1234567

-----Sample Output:-----
4

1

-----EXPLANATION:-----
For first test case
$\textbf{$\underline{2323}$}$ is a “good” group because there are no players who are left unmatched first and third player form pair and second and fourth player form pair.

For second test

Only length one "good" group is possible.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import sys\r\nimport math\r\nfrom collections import defaultdict,Counter\r\n\r\n# input=sys.stdin.readline\r\n# def print(x):\r\n#     sys.stdout.write(str(x)+"\\n")\r\n\r\n# sys.stdout=open("CP1/output.txt",\'w\')\r\n# sys.stdin=open("CP1/input.txt",\'r\')\r\n\r\ndef possible(n1,n):\r\n\t# d=defaultdict(int)\r\n\todd=set()\r\n\t# even=set()\r\n\tfor j in range(n):\r\n\t\t# print(odd)\r\n\t\tif s[j] in odd:\r\n\t\t\todd.remove(s[j])\r\n\t\t\t# even.add(s[j])\r\n\t\telse:\r\n\t\t\todd.add(s[j])\r\n\t\t# d[s[j]]+=1\r\n\t\t# print(odd)\r\n\t\tif j<n1-1:\r\n\t\t\tcontinue\r\n\t\t# print(j)\r\n\t\tif len(odd)<=1:\r\n\t\t\treturn True\r\n\r\n\t\tif s[j-n1+1] in odd:\r\n\t\t\todd.remove(s[j-n1+1])\r\n\t\t\t# even.add(s[j])\r\n\t\telse:\r\n\t\t\todd.add(s[j-n1+1])\r\n\treturn False\r\n# m=pow(10,9)+7\r\nt=int(input())\r\nfor i in range(t):\r\n\ts=input().strip()\r\n\tn=len(s)\r\n\tans=0\r\n\tfor j in range(n,0,-1):\r\n\t\tif possible(j,n):\r\n\t\t\tans=j\r\n\t\t\tbreak\r\n\tprint(ans)\r\n\t# low=1\r\n\t# high=n\r\n\t# while low<=high:\r\n\t# \tmid=(low+high)//2\r\n\t# \tif mid%2==0:\r\n\t# \t\tif low%2==0:\r\n\t# \t\t\tlow+=1\r\n\t# \t\t\tmid+=1\r\n\t# \t\telif high%2==0:\r\n\t# \t\t\thigh-=1\r\n\t# \t\t\tmid-=1\r\n\t# \t# if low>high:\r\n\t# \t# \tbreak\r\n\t# \tif possible(mid,n):\r\n\t# \t\tlow=mid+1\r\n\t# \telse:\r\n\t# \t\thigh=mid-1\r\n\t# \tprint(mid,low,high)\r\n\t# print(mid)\r\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13681