program Noname4;
var x, y, kiek, n, i: integer;
imk, ats : text;
skirst : string;
begin
x:= 1;
y:= 1;
Assign(imk,'info.txt');
reset(imk);
readln(imk,n);
if (n < 1) or (n > 50) then
write('Iseita is ribojimo');
readln(imk, kiek);
if (kiek < 1) or (kiek > 1000) then
write('Iseita is ribojimo');
for i:= 1 to kiek do
begin
readln(imk,skirst);
if skirst = 'V' then
x:= x - 1
else if skirst = 'R' then
x:= x + 1
else if skirst = 'P' then
y:= y + 1
else if skirst = 'S' then
y:= y - 1;
if x = 0 then
x:= 1;
if y = 0 then
y:= 1;
if x = n + 1 then
x:= n;
if y = n + 1 then
y:= n;
end;
assign(ats,'rez.txt');
rewrite(ats);
write(ats,x,' ',y);
close(ats);
close(imk);
Readln;
end.