Robot Instructions
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
string a[110];
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
int x=0;
for (int i=1;i<=n;i++){
string s;
cin>>s;
if (s=="LEFT"){
x--;
a[i]="LEFT";
}
else if (s=="RIGHT"){
x++;
a[i]="RIGHT";
}
else{
string ss;
int m;
cin>>ss;
scanf("%d",&m);
if (a[m]=="LEFT"){
x--;
a[i]="LEFT";
}
else if (a[m]=="RIGHT"){
x++;
a[i]="RIGHT";
}
}
}
printf("%d\n",x);
}
return 0;
}