intmain() { cin>>n>>m; for(int i=1;i<=n;i++) { int x; cin>>x; tree[i]=x; int t=i; while(t>1&&tree[t]<tree[t>>1]) { swap(tree[t],tree[t>>1]); t>>=1; } tree[t]=x; } for(int i=1;i<=n;i++)s[tree[i]]=i; while(m--) { int x,y; char str[50]; scanf("%d%s",&x,&str); if(str[0]=='a')//x and y are siblings { scanf("%d%s%s",&y,&str,&str); if(s[x]>>1==s[y]>>1)printf("T\n");elseprintf("F\n"); } else { scanf("%s",&str); if(str[0]=='a')//x is a child of y { scanf("%s%s%d",&str,&str,&y); if(s[x]>>1==s[y])printf("T\n");elseprintf("F\n"); } else { scanf("%s",&str); if(str[0]=='r')//x is the root { if(s[x]==1)printf("T\n");elseprintf("F\n"); } else//x is the parent of y { scanf("%s%d",&str,&y); if(s[y]>>1==s[x])printf("T\n");elseprintf("F\n"); } } } } return0; }