The notorious hacker group "Sed" managed to obtain a string $S$ from their secret sources. The string contains only lowercase English letters along with the character '?'.
A substring of $S$ is a contiguous subsequence of that string. For example, the string "chef" is a substring of the string "codechef", but the string "codeh" is not a substring of "codechef".
A substring of $S$ is good if it is possible to choose a lowercase English letter $C$ such that the following process succeeds:
- Create a string $R$, which is a copy of the substring, but with each '?' replaced by the letter $c$. Note that all occurrences of '?' must be replaced by the same letter.
- For each lowercase English letter:
- Compute the number of times it occurs in $S$ and the number of times it occurs in $R$; let's denote them by $A$ and $B$ respectively. The '?' characters in the original string $S$ are ignored when computing $A$.
- Check the parity of $A$ and $B$. If they do not have the same parity, i.e. one of them is even while the other is odd, then this process fails.
- If the parities of the number of occurrences in $S$ and $R$ are the same for each letter, the process succeeds.
For different substrings, we may choose different values of $C$.
Help Sed find the number of good substrings in the string $S$.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains a single string $S$.

-----Output-----
For each test case, print a single line containing one integer ― the number of good substrings.

-----Constraints-----
- $1 \le T \le 10^5$
- $1 \le S \le 10^5$
- $S$ contains only lowercase English letters ('a' through 'z') and '?'
- the sum of $|S|$ over all test cases does not exceed $10^5$

-----Example Input-----
5
aa?
a???
????
asfhaslskfak
af??avvnfed?fav?faf????

-----Example Output-----
2
6
4
2
27

-----Explanation-----
Example case 1: All letters occur an even number of times in $S$. The six substrings of $S$ are "a", "a", "?", "aa", "a?" and "aa?" (note that "a" is counted twice). Which of them are good?
- "a" is not good as 'a' occurs an odd number of times in this substring and there are no '?' to replace.
- "?" is also not good as replacing '?' by any letter causes this letter to occur in $R$ an odd number of times.
- "aa" is a good substring because each letter occurs in it an even number of times and there are no '?' to replace.
- "a?" is also a good substring. We can replace '?' with 'a'. Then, $R$ is "aa" and each letter occurs in this string an even number of times. Note that replacing '?' e.g. with 'b' would not work ($R$ would be "ab", where both 'a' and 'b' occur an odd number of times), but we may choose the replacement letter $C$ appropriately.
- "aa?" is not a good substring. For any replacement letter $C$, we find that $C$ occurs an odd number of times in $R$.
Example case 2: We especially note that "a???" is not a good substring. Since all '?' have to be replaced by the same character, we can only get strings of the form "aaaa", "abbb", "accc", etc., but none of them match the criteria for a good substring.
Example case 3: Any substring with even length is good.

```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 = '# from sys import stdin, stdout\n# from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log\n# from collections import defaultdict as dd, deque\n# from heapq import merge, heapify, heappop, heappush, nsmallest\n# from bisect import bisect_left as bl, bisect_right as br, bisect\n# mod = pow(10, 9) + 7\n# mod2 = 998244353\n# def inp(): return stdin.readline().strip()\n# def out(var, end="\\n"): stdout.write(str(var)+"\\n")\n# def outa(*var, end="\\n"): stdout.write(\' \'.join(map(str, var)) + end)\n# def lmp(): return list(mp())\n# def mp(): return map(int, inp().split())\n# def smp(): return map(str, inp().split())\n# def l1d(n, val=0): return [val for i in range(n)]\n# def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n# def remadd(x, y): return 1 if x%y else 0\n# def ceil(a,b): return (a+b-1)//b\n\n# def isprime(x):\n#     if x<=1: return False\n#     if x in (2, 3): return True\n#     if x%2 == 0: return False\n#     for i in range(3, int(sqrt(x))+1, 2):\n#         if x%i == 0: return False\n#     return True\n    \n# def bitmsk(s):\n#     md = {}\n#     S = "abcdefghijklmnopqrstuvwxyz"\n#     for i in S:\n#         md[i]=0\n#     for i in s:\n#         if i in md: md[i]+=1\n#     b = ""\n#     for i in S:\n#         b+=\'1\' if md[i]%2 else \'0\'\n#     return b\n\n# def xor(a, b):\n#     c = ""\n#     for i in range(27):\n#         if (a[i]==\'0\' and b[i]==\'0\') or (a[i]==\'1\' and b[i]==\'1\'): c += \'0\'\n#         else: c += \'1\'\n#     return c\n\n# for _ in range(int(inp())):\n#     s = inp()\n#     l = len(s)\n#     b = bitmsk(s)\n#     b += \'0\'\n#     good = []\n#     good.append(b)\n#     b = b[:-1]\n#     for i in range(26):\n#         x = \'1\' if b[i]==\'0\' else \'0\'\n#         good.append(b[:i]+x+b[i+1:]+\'1\')\n#     pre = [\'0\'*27]\n#     cq = 0\n#     mdd = {}\n#     for i in range(l):\n#         if s[i]==\'?\': cq+=1\n#         k = \'1\' if cq%2 else \'0\'\n#         kk = bitmsk(s[:i+1])+k\n#         pre.append(kk)\n#         if kk in mdd: mdd[kk].append((i+1))\n#         else: mdd[kk]=[(i+1)]\n#     # print(pre)\n#     ans = 0\n#     for i in range(l):\n#         # for j in range(i+1, l+1):\n#         #     if xor(pre[i], pre[j]) in good:\n#         #         ans += 1\n#         for j in good:\n#             xx = xor(pre[i], j)\n#             if xx in mdd:\n#                 ans += len(mdd[xx])-br(mdd[xx], i)\n#     out(ans)\n\n# cook your dish here\nfrom sys import stdin, stdout\nfrom math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque\nfrom heapq import merge, heapify, heappop, heappush, nsmallest\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nmod = pow(10, 9) + 7\nmod2 = 998244353\ndef inp(): return stdin.readline().strip()\ndef out(var, end="\\n"): stdout.write(str(var)+"\\n")\ndef outa(*var, end="\\n"): stdout.write(\' \'.join(map(str, var)) + end)\ndef lmp(): return list(mp())\ndef mp(): return map(int, inp().split())\ndef smp(): return map(str, inp().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\ndef remadd(x, y): return 1 if x%y else 0\ndef ceil(a,b): return (a+b-1)//b\n\ndef isprime(x):\n    if x<=1: return False\n    if x in (2, 3): return True\n    if x%2 == 0: return False\n    for i in range(3, int(sqrt(x))+1, 2):\n        if x%i == 0: return False\n    return True\n    \ndef xor(a, b):\n    c = ""\n    for i in range(27):\n        if (a[i]==\'0\' and b[i]==\'0\') or (a[i]==\'1\' and b[i]==\'1\'): c += \'0\'\n        else: c += \'1\'\n    return c\n\nfor _ in range(int(inp())):\n    s = inp()\n    l = len(s)\n    md = {}\n    S = "abcdefghijklmnopqrstuvwxyz"\n    for i in S:\n        md[i]=0\n        \n    cq = 0\n    mdd = {}\n    pre = [\'0\'*27]\n    for i in range(l):\n        if s[i] in md: md[s[i]]+=1\n        b = ""\n        for j in S:\n            b+=\'1\' if md[j]%2 else \'0\'\n        if s[i]==\'?\': cq+=1\n        k = \'1\' if cq%2 else \'0\'\n        kk = b+k\n        pre.append(kk)\n        if kk in mdd: mdd[kk].append((i+1))\n        else: mdd[kk]=[(i+1)]\n        \n    b = pre[-1]\n    good = []\n    good.append(b[:-1]+\'0\')\n\n    b = b[:-1]\n    for i in range(26):\n        x = \'1\' if b[i]==\'0\' else \'0\'\n        good.append(b[:i]+x+b[i+1:]+\'1\')\n    alpha = {}\n    S = "abcdefghijklmnopqrstuvwxyz?"\n    for i in range(27):\n        alpha[S[i]] = i\n    \n    ans = 0\n    for j in good:\n        prev = j\n        for i in range(l+1):\n            if i != 0:\n                x = alpha[s[i-1]]\n                kk = \'0\' if prev[x] == \'1\' else \'1\'\n                prev = prev[:x]+kk+prev[x+1:]\n            if prev in mdd:\n                ans += len(mdd[prev])-br(mdd[prev], i)\n    out(ans)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 24248