#include #include #include #include using namespace std; char s[300010]; int main() { int t; cin >> t; while (t--) { cin >> s; int n = strlen(s); int ans[30] = {}; ans[0] = (n + 1)% 2; int cnt = 1; for (int i = 0; i <= n; i++) { if (s[i] == '?')cnt++; else { for (int j = 1; j < 30; j++) { if (cnt&(1 << j)) { if (ans[j] == 0)ans[j] = 1; else { for (int k = 1; k < j; k++) { ans[k] = 1; } } } } cnt = 1; } } int p = 0; for (int i = 0; i < 30; i++) { p += ans[i] ? (1 << i) : 0; } cout << p << endl; } }