#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main(){ int c,l,m,len[10005],p1,p2,s1,s2; char lr[10005][10]; scanf("%d",&c); while(c--){ scanf("%d%d",&l,&m); l *= 100; for(int i=0;i<m;i++){ scanf("%d%s",&len[i],lr[i]); } p1 = p2 = 1; s1 = s2 = 0; for(int i=0;i<m;i++){ if(strcmp(lr[i],"left")==0){ s1 += len[i]; if(s1>l){ s1 = 0; p1++; i--; } } else{ s2 += len[i]; if(s2>l){ s2 = 0; p2++; i--; } } } if(p1>p2)printf("%d\n",p1*2-1); else printf("%d\n",p2*2); } return 0; }