#include <bits/stdc++.h> 
using namespace std;

typedef long long                       ll;
typedef long double                     ld;
typedef pair<int,int>                   pii;

#define F                               first
#define S                               second
#define pb(x)                           push_back(x)
#define eb(x)                           emplace_back(x)

const ll INF=1e9;
const int MOD=998244353;

void solve(){
    string a; 
    cin>>a;
    int n=a.length();
    ll ans=0;
    for(int i=0;i<2;i++){
        vector<int> bad;
        bad.pb(-1);
        for(int j=0;j<n;j++){
            if(a[j]=='?') continue;
            if(a[j]-'0'!=(j+i)%2){
                bad.pb(j);
            }
        }
        bad.pb(n);
        for(int j=0;j+1<bad.size();j++){
            ll temp=bad[j+1]-bad[j];
            ans+=(temp)*(temp-1)/2;
        }
    }
    vector<int> bad;
    bad.pb(-1);
    for(int i=0;i<n;i++){
        if(a[i]=='?') continue;
        bad.pb(i);
    }
    bad.pb(n);
    for(int i=0;i+1<bad.size();i++){
        ll temp=bad[i+1]-bad[i];
        ans-=temp*(temp-1)/2;
    }
    cout<<ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
}
