//...AKASH KESHRI...//
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
void solve() {
    string s;
    cin>>s;
    ll l=s.length();
    ll ans=1;
    vector<vector<int>>dp(l,vector<int>(2,0));
        if(s[0]=='0')
        {
            dp[0][0]=1;
        }
       else if(s[0]=='1')
        {
            dp[0][1]=1;
        }
        else
        {
            dp[0][0]=dp[0][1]=1;
        }
    for(int i=1;i<l;i++)
    {
        if(s[i]=='0')
        {
            dp[i][0]=1+dp[i-1][1];
        }
       else if(s[i]=='1')
        {
            dp[i][1]=1+dp[i-1][0];
        }
        else
        {
            dp[i][0]=1+dp[i-1][1];
            dp[i][1]=1+dp[i-1][0];
        }
        ans+=max(dp[i][0],dp[i][1]);
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

