#include<cstdlib>
#include<cstdio>
#include<cstring>
struct Ant{
int pos;
int srazky;
bool dir; // true = left
bool spadneDir;
};
int compare(const void* a,const void* b){
Ant* aa = (Ant*)a;
Ant* bb = (Ant*)b;
return aa->pos - bb->pos;
}
#define antsSize 100005
int main()
{
Ant ants[antsSize];
int antsNum,length;
while(scanf("%d%d",&length,&antsNum)==2){
int pos;char dir;
for(int i=0; i<antsNum; i++){
scanf("%d %c",&pos,&dir);
ants[i].pos = pos;
ants[i].dir = (dir == 'L');
}
qsort((void*)ants,antsNum,sizeof(Ant),compare);
int timeL = 0,timeR = 0, timeMax;
int i = 0;
while(timeR==0 && i < antsNum){
if(ants[i].dir == false)timeR = length - ants[i].pos;
i++;
}
i = antsNum-1;
while(timeL==0 && i>=0){
if(ants[i].dir == true)timeL = ants[i].pos;
i--;
}
if(timeL > timeR) timeMax = timeL;
else timeMax = timeR;
char vsichni = 0;
// orezani tech, ktery se nesrazi a spadnou
int orezLeft = 0; // index mravence, ktery jeste nespadne
while(ants[orezLeft].dir == true){
orezLeft++;
if(orezLeft==antsNum){
vsichni ='L';
break; // všichni spadnou doleva
}
}
int orezRight = antsNum - 1; // index mravence, ktery jeste nespadne
while(ants[orezRight].dir == false){
orezRight--;
if(orezRight==-1){
vsichni ='R';
break; // všichni spadnou doprava
}
}
for(int i=orezLeft; i<antsNum; i++){
if(ants[i].dir == true){
ants[i].srazky = 2*(i-orezLeft);
} else{
ants[i].srazky = 2*(i-orezLeft) + 1;
}
ants[i].spadneDir = true;
}
for(int i= orezRight/*(antsNum - 1)*/; i>=orezLeft; i--){
if(ants[i].dir == true){
if(ants[i].srazky > (2*(orezRight-i) + 1) ) {
ants[i].srazky = 2*(orezRight-i) + 1;
ants[i].spadneDir = false;
}
else{
//break; // muzeme preskocit zbytek? tnz budou uz vsichni mit srazku nizsi
}
} else{
if(ants[i].srazky > (2*(orezRight-i)) ) {
ants[i].srazky = 2*(orezRight-i);
ants[i].spadneDir = false;
}
else{
//break;
}
}
}
if(vsichni == 'R'){
printf("The last ant will fall down in %d seconds - started at %d.\n", timeMax, ants[0].pos);
continue;
}
if(vsichni == 'L'){
printf("The last ant will fall down in %d seconds - started at %d.\n", timeMax, ants[antsNum-1].pos);
continue;
}
//printf("times %d %d\n",timeL,timeR);
int pos2=0xFF,pos3=-1;
if(timeL==timeR){
//printf("tu\n");
for(i = antsNum-1;i>=0;i--){
//printf("%d Spadne %d\n",i,ants[i].spadneDir);
if(ants[i].spadneDir==true){
pos2 = ants[i].pos;
break;
}
}
for(i = 0;i<antsNum;i++){
if(ants[i].spadneDir==false){
pos3 = ants[i].pos;
break;
}
}
}else{
if(timeL==timeMax){
for(i = antsNum-1;i>=0;i--){
if(ants[i].spadneDir==true){
pos2 = ants[i].pos;
break;
}
}
}else{
for(i = 0;i<antsNum;i++){
if(ants[i].spadneDir==false){
pos2 = ants[i].pos;
break;
}
}
}
}
//printf("padne pos %d %d\n",pos2,pos3);
if(pos3==-1){
printf("The last ant will fall down in %d seconds - started at %d.\n", timeMax, pos2);
}
else{
if(pos3<pos2){
int pomoc = pos3;
pos3 = pos2;
pos2 = pomoc;
}
printf("The last ant will fall down in %d seconds - started at %d and %d.\n", timeMax, pos2,pos3);
}
//printf("Ořezy: %d %d\n",orezLeft, orezRight);
for(int i = orezLeft; i<= orezRight; i++){
//printf("%d ",ants[i].srazky);
}
}
return 0;
}
/*
for(int i=0;i<10;i++)
{
}
scanf("%d",&);
printf("%d");
*/