#include <stdio.h>
#include <list>
#include <iostream>
class Ant
{
public:
int facing;
int pos;
Ant(int fac, int p) : facing(fac), pos(p) {}
};
#define FACE_R 0
#define FACE_L 1
bool swapped;
void swap(int & a, int & b)
{
int temp = a;
a = b;
b = temp;
swapped = true;
}
using namespace std;
bool compare(const Ant & a, const Ant & b)
{
if (a.pos < b.pos)
return 1;
return 0;
}
int main()
{
int ants_num, lumber_size;
int ant1, ant2 = -1;
int max_length = 0;
int number_facings = 0;
list<Ant> ants_array;
while(scanf("%d%d", &lumber_size, &ants_num) == 2)
{
ants_array.clear();
max_length = 0;
number_facings = 0;
ant2 = -1;
for (int i = 0; i < ants_num; i++)
{
int pos;
char facing;
scanf("%d %c", &pos, &facing);
ants_array.insert(ants_array.end(), Ant(facing == 'R' ? FACE_R : FACE_L, pos));
int distance = facing == 'R' ? lumber_size - pos : pos;
if (distance > max_length)
max_length = distance;
if (facing == 'L')
number_facings++;
}
ants_array.sort(compare);
list<Ant>::iterator itr = ants_array.begin();
for (int i = 0; i < number_facings; i++)
{
itr++;
}
list<Ant>::iterator first = ants_array.begin();
list<Ant>::iterator last = --ants_array.end();
int num2 = itr->pos;
itr--;
int num1 = itr->pos;
ant1 = 0;
while (first->facing == FACE_L && first != ants_array.end())
first++;
while (last->facing == FACE_R && last != ants_array.begin())
last--;
if (first != ants_array.end() && first->pos > lumber_size - last->pos)
{
ant1 = num1;
}
if (first != last && first->pos < lumber_size - last->pos)
{
ant1 = num2;
}
if (first != last && first != ants_array.end() && first->pos == lumber_size - last->pos)
{
ant1 = num1;
ant2 = num2;
}
/*
if (itr == ants_array.end())
{
ant1 = (--itr)->pos;
}
else
if (itr == ants_array.begin())
{
ant1 = itr->pos;
}
else
{
int pos1 = lumber_size - itr->pos;
int num1 = itr->pos;
int pos2 = (--itr)->pos;
int num2 = itr->pos;
cout << num1 << " "<< num2 << endl;
if (pos1 > pos2)
ant1 = num1;
else if (pos1 < pos2)
ant1 = num2;
else
{
ant1 = num1;
ant2 = num2;
}
}*/
printf("The last ant will fall down in %d seconds - started at %d",max_length, ant1);
if ( ant2 != -1)
printf(" and %d",ant2);
printf(".\n");
}
}