#include #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) #define REP(i,n) for(int i=(0);i<(n);i++) #define fi first #define se second #define pb push_back #define mp make_pair using namespace std; typedef pair pii; typedef vector vi; typedef long long ll; template inline void read(T &x){ int f=0;x=0;char ch=getchar(); for(;!isdigit(ch);ch=getchar())f|=(ch=='-'); for(;isdigit(ch);ch=getchar())x=x*10+ch-'0'; if(f)x=-x; } const int N=(1<<20)+5; int lg[N],n,res; char s[N]; void MAIN(){ scanf("%s",s+1); n=strlen(s+1),res=0; int las=0; rep(i,1,n+1) if(s[i]=='^'||i==n+1){ int now=(i-las)/2; //cerr<>i&1)&&(now>=(1<>1]+1; while(T--) MAIN(); return 0; }