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

typedef pair<int,int> pii;
typedef pair<string,int> psi;
typedef pair<int,string> pis;
typedef array<int,2> aii;
typedef array<int,3> aiii;
typedef array<int,4> aiiii;
typedef unsigned long long ull;
typedef long long int ll;
typedef array<ll,2> all;
typedef array<ll,3> alll;
typedef array<ll,4> allll;

#define pb push_back
#define ff first
#define ss second
#define MAX 200005
#define MOD 1000000007
#define INF 1e9
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<aiii>adj[MAX];
int xMove[] = { 0,1,0,-1,1,1,-1,-1, 2, 2, -2, -2, 1, 1, -1, -1 };
int yMove[] = { 1,0,-1,0,1,-1,1,-1, 1, -1, 1, -1, 2, -2, 2, -2 };
string s;

int dp[MAX][2],n;

int solve(int i, int p)
{
    if(i==n)
        return 0;
    if(dp[i][p]!=-1)
        return dp[i][p];

    int ans=0;
    if(s[i]=='1')
    {
        if(p==0)
            ans=1+solve(i+1,1);
    }
    else if(s[i]=='0')
    {
        if(p==1)
            ans=1+solve(i+1,0);
    }
    else
    {
        if(p==0)
            ans=1+solve(i+1,1);
        else ans=1+solve(i+1,0);
    }

    return dp[i][p]=ans;
}
int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.txt","w",stdout);
    cin.tie(0),cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);
    int TC=1;
    int m,k,q;

    cin>>TC;
    for(int t1=1; t1<=TC; t1++)
    {
        cin>>s;
        n=s.size();
        for(int i=0;i<s.size();i++)
            dp[i][0]=-1,dp[i][1]=-1;

        ll ans=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]=='0')
                ans+=1+solve(i+1,0);
            else if(s[i]=='1')
                ans+=1+solve(i+1,1);
            else ans+=max(1+solve(i+1,0),1+solve(i+1,1));
        }

        cout<<ans<<"\n";
    }

    return 0;
}
