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 = 'def convertToParitys(s):\r\n    """\r\n    This converts the string s to an int, which is a bitMap of the parity of each letter\r\n    odd ? = first bit set\r\n    odd a = second bit set\r\n    odd b = third bit set \r\n    etc\r\n    """\r\n    keys = \'?abcdefghijklmnopqrstuvwxyz\'\r\n    paritys = {c:0 for c in keys}\r\n    for c in s:\r\n        paritys[c] += 1\r\n    for c, v in paritys.items():\r\n        paritys[c] = v%2\r\n    \r\n    out = 0\r\n    bitValue = 1\r\n    for c in keys:\r\n        if paritys[c]:\r\n            out += bitValue\r\n        bitValue *= 2\r\n    return out\r\n\r\ndef getSolutionBitMaps(s):\r\n    """\r\n    these are the 27 valid bitmaps that a substring can have\r\n    even ? and the parities the same\r\n    26 cases of odd ? and one bit different in the parity compared to s\r\n    """\r\n    out = []\r\n    sP = convertToParitys(s)\r\n    if sP%2:\r\n        sP -= 1 # to remove the \'?\' parity\r\n    #even case - \r\n    out.append(sP)\r\n    #odd cases - need to xor sP with 1 + 2**n n = 1 to 26 inc to flip ? bit and each of the others\r\n    for n in range(1,27):\r\n        out.append(sP^(1+2**n))\r\n    return out\r\n\r\ndef getLeadingSubStringBitMapCounts(s):\r\n    """\r\n    This calculates the bit map of each of the len(s) substrings starting with the first character and stores as a dictionary.\r\n    Getting TLE calculating each individually, so calculating with a single pass\r\n    """\r\n    out = {}\r\n    bM = 0\r\n    keys = \'?abcdefghijklmnopqrstuvwxyz\'\r\n    paritys = {c:0 for c in keys}\r\n    values = {c:2**i for i,c in enumerate(keys)}\r\n    out[bM] = out.setdefault(bM, 0) + 1  #add the null substring\r\n    bMis = []\r\n    i = 0\r\n    bMis = [0]\r\n    for c in s:\r\n        i += 1\r\n        if paritys[c]:\r\n            paritys[c] = 0\r\n            bM -= values[c]\r\n        else:\r\n            paritys[c] = 1\r\n            bM += values[c]\r\n        out[bM] = out.setdefault(bM, 0) + 1\r\n        bMis.append(bM)\r\n    return out,bMis\r\n\r\ndef solve(s):\r\n    out = 0\r\n    bMjCounts,bMis = getLeadingSubStringBitMapCounts(s)\r\n    #print(\'bMjCounts\')\r\n    #print(bMjCounts)\r\n    solutions = getSolutionBitMaps(s)\r\n    #print(\'solutions\')\r\n    #print(solutions)    \r\n    for bMi in bMis:\r\n        for bMs in solutions:\r\n            if bMs^bMi in bMjCounts:\r\n                out += bMjCounts[bMs^bMi]\r\n                #print(i,bMi,bMs,bMs^bMi,bMjCounts[bMs^bMi])\r\n    if 0 in solutions:\r\n        out -= len(s) #remove all null substrings\r\n    out //= 2 # since j may be less that i each substring is counted twice\r\n    return out\r\n                \r\nT = int(input())\r\nfor tc in range(T):\r\n    s = input()\r\n    print(solve(s))\r\n    '
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13481