#include #define N 2100000 using namespace std; int n; int que[N],top; char str[N]; inline void Rd(int &res){ char c;res=0; while(c=getchar(),c<48); do res=(res<<3)+(res<<1)+(c^48); while(c=getchar(),c>47); return; } inline bool cmp(int a,int b){ return a>b; } int main(){ int T; Rd(T); while(T--){ scanf("%s",str+1);n=strlen(str+1);top=0; int last=0; for(int i=1;i<=n;i++){ if(str[i]=='^')que[++top]=last+1,last=0; else last++; } que[++top]=last+1; sort(que+1,que+top+1,cmp); int now=que[1]; for(int i=2;i<=top;i++){ bool flag=0; for(int j=20;j>=1;j--){ if(now&(1<