import std.stdio;
import std.ascii;
import std.algorithm;
import core.stdc.stdio;

int main()
{
    int t = readInt!int;
    foreach(ti; 0 .. t)
    {
        string str = readString;
        auto a = new int[](str.length);
        foreach(i, ref ai; a)
            switch(str[i])
            {
            case '0': ai = 0 ^ (i & 1); continue;
            case '1': ai = 1 ^ (i & 1); continue;
            default: ai = -1; continue;
            }
        debug writeln(a);
        int c0 = 0;
        int c1 = 0;
        long result = 0;
        foreach(i, ai; a)
        {
            if (ai == 0) c0++, c1 = 0;
            if (ai == 1) c1++, c0 = 0;
            if (ai == -1) c0++, c1++;
            if (ai == 0) result += c0;
            if (ai == 1) result += c1;
            if (ai == -1) result += max(c0, c1);
        }
        result.writeln;
    }
    return 0;
}


/* INPUT ROUTINES */
int currChar;
static this()
{
    currChar = getchar();
}
char topChar()
{
    return cast(char) currChar;
}
void popChar()
{
    currChar = getchar();
}
auto readInt(T)()
{
    T num = 0;
    int sgn = 0;
    while (topChar.isWhite) popChar;
    while (topChar == '-' || topChar == '+') { sgn ^= (topChar == '-'); popChar; }
    while (topChar.isDigit) { num *= 10; num += (topChar - '0'); popChar; }
    if (sgn) return -num; return num;
}
string readString()
{
    string res = "";
    while (topChar.isWhite) popChar;
    while (!topChar.isWhite) { res ~= topChar; popChar; }
    return res;
}
/**MODULAR SYSTEM*/
struct Z(immutable long m)
{
    long rep;
    this(long num)
    {
        rep = num;
    }
    Z!m opBinary(string operator)(Z!m rhs)
    {
        static if (operator == "+")
        {
            long result = rhs.rep + this.rep;
            if (result >= m) result -= m;
            return Z!m(result);
        }
        else static if (operator == "-")
        {
            long result = this.rep - rhs.rep;
            if (result < 0) result += m;
            return Z!m(result);
        }
        else static if (operator == "*")
        {
            long result = this.rep * rhs.rep;
            if (result >= m) result %= m;
            return Z!m(result);
        } else static assert(text("Operator ", operator, " not supported"));
    }
    Z!m opBinary(string operator)(long exponent) if (operator == "^^")
    {
        assert(exponent >= 0);
        Z!m base = this;
        Z!m result = 1;
        while (exponent)
        {
            if (exponent & 1)
                result = result * base;
            base = base * base;
            exponent >>= 1;
        }
        return result;
    }
    invariant
    {
        assert(rep >= 0 && rep < m);
    }
}
