#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define endl "\n"
#define F first
#define S second
#define pp pop_back
ll mod = 1e9+7;
ll dp[200200][2];
ll st[200200];
ll n;

ll rec(ll level,int curr){
    if(st[level]==1||st[level]==0){
        if(curr!=st[level])return 0;
    }
    if(level==n-1){
        return 1;
    }
    if(dp[level][curr]!=-1)return dp[level][curr];
    return dp[level][curr] = 1+rec(level+1,1-curr);
}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t;cin>>t;
    while(t--){
        memset(dp,-1,sizeof(dp));memset(st,-1,sizeof(st));
        string s;cin>>s;
        n = (ll)s.size();
        for(ll i=0;i<n;i++){
            if(s[i]=='1' ||s[i]=='0'){st[i]=s[i]-'0';}
            else{
                st[i]=3;
            }
        }
        ll ans = 0;
        for(int i=0;i<n;i++){
            ans+=max(rec(i,1),rec(i,0));
        }
        cout<<ans<<endl;
    }
    return 0;
}
