#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l,long long r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define gg exit(0)
#define int long long
const int N=200010;
int a[N], f[N][2];
signed main()
{
    int t; cin >> t;
    while(t--)
    {
        memset(f,0,sizeof(f));
        string s; cin >> s;
        int n=s.size();
        forinc(i,1,n)
        {
            a[i]=s[i-1]-'0';
            if(a[i]!=0&&a[i]!=1) a[i]=2;
        }
        forinc(i,1,n)
        {
            forinc(j,0,1) if(a[i]==j||a[i]==2) f[i][j]=f[i-1][1-j]+1;
        }
        int res=0;
        forinc(i,1,n)
        {
            forinc(j,0,1)
            {
                //cout << f[i][j] << " ";
            }
            res+=max(f[i][0],f[i][1]);
            //cout << "\n";
        }
        cout << res << "\n";
    }
}

