#include <bits/stdc++.h>
#define ll long long 
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//int gcd(int a,int b){if(a == 0) return b; return gcd(b%a,a);}

void solve()
{
    string s;
    int n;
    cin>>s;
    n=s.length();
    
	ll ans = 0,len=0;
	
	for(int i=0;i<n;i++){
		if(s[i]=='?') len++;
		else if(i&1 && s[i]=='0'){
			len++;
		}
		else if(!(i&1) && s[i]=='1'){
			len++;
		}
		else{
			ans += len*(len+1)/2;
			len = 0;
		}
	}
	
	ans += len*(len+1)/2;
	len = 0;
	
	for(int i=0;i<n;i++){
		if(s[i]=='?') len++;
		else if(!(i&1) && s[i]=='0'){
			len++;
		}
		else if((i&1) && s[i]=='1'){
			len++;
		}
		else{
			ans += len*(len+1)/2;
			len = 0;
		}
	}
	
	ans += len*(len+1)/2;
	len = 0;
	
	for(int i=0;i<n;i++){
		if(s[i]=='?') len++;
		else{
			ans -= len*(len+1)/2;
			len = 0;
		}
	}
		
	ans -= len*(len+1)/2;
		
	cout<<ans<<endl;
}
int main()
{
	ios;
	int t;
	cin>>t;
	for(;t--;)
	{
	    solve();
	}
    return 0;
}

