#include <iostream>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;

int arr[2][2],t,ans;
string s;
void init();

signed main(){
    ios_base::sync_with_stdio(0);
    cin>>t;
    while(t--){
        cin>>s;
        init();
        for(int i=0,j,p;i<s.size();++i){
            j=i-1,p=i&1;
            if(s[i]!='0')j=min(j,max(arr[1][p^1],arr[0][p]));
            if(s[i]!='1')j=min(j,max(arr[0][p^1],arr[1][p]));
            ans+=i-j;
            if(s[i]!='?')arr[s[i]-'0'][p]=i;
        }
        cout<<ans<<"\n";
    }
}

void init(){
    arr[0][0]=arr[0][1]=arr[1][0]=arr[1][1]=-1;
    ans=0;
}
