help me
const dir :array [1..4,1..2] of shortint=((1,0),(0,1),(-1,0),(0,-1));
sign:array [1..4] of char=('R','T','L','B');
type rec=record
x0,y0:integer;
end;
var xx,yy,i,n,j,x,y :integer;
head,tail :integer;
note1 :array [1..100] of rec;
note2 :array [1..100] of string;
a :array [1..100,1..100] of byte;
f,m :byte;
procedure init;
var t1,t2 :string;
st :string;
begin
for i:=1 to 100 do for j:=1 to 100 do a[i,j]:=0;
readln(t1);readln(t2);
if t2='.' then begin writeln(1);writeln(ord(t1[1])-48,' ',ord(t1[3])-
48);halt;end;
for i:=1 to length(t2) do if ord(t2[i])>60 then begin f:=1;break;end
else f:=2;
if f=2 then
begin
n:=ord(t1[1])-48;
note1[1].x0:=ord(t2[1])-48;note1[1].y0:=ord(t2[3])-48;
for i:=2 to n do
begin read(x,y);a[x,y]:=1;end;
end
else
begin
note1[1].x0:=ord(t1[1])-48;note1[1].y0:=ord(t1[3])-48;
m:=0;st:=t2;
repeat
inc(m);
if m=1 then note2[m]:=ST else begin readln(st);note2[m]:=st;end;
until st='.';
end;
head:=0;tail:=1;
end;
procedure work2;
begin
writeln(note1[1].x0,' ',note1[1].y0);
repeat
inc(head);
for i:=1 to 4 do
if a[note1[head].x0+dir[i,1],note1[head].y0+dir[i,2]]=1 then
begin
inc(tail);
note1[tail].x0:=note1[head].x0+dir[i,1];
note1[tail].y0:=note1[head].y0+dir[i,2];
a[note1[tail].x0,note1[tail].y0]:=0;
write(sign[i])
end;
if head<>tail then writeln(',');
until head>=tail;
write('.');
end;
procedure work1;
var t:rec;
begin
writeln(m);
repeat
inc(head);
for i:=1 to 4 do
if pos(sign[i],note2[head])<>0 then
begin
inc(tail);
note1[tail].x0:=note1[head].x0+dir[i,1];
note1[tail].y0:=note1[head].y0+dir[i,2];
end;
until head=tail;
for i:=1 to m do
for j:=i+1 to m do
if note1[i].x0>note1[j].x0 then
begin t:=note1[i];note1[i]:=note1[j];note1[j]:=t;end;
for i:=1 to m do
for j:=i+1 to m do
if note1[i].x0=note1[j].x0 then
if note1[i].y0>note1[j].y0 then
begin t:=note1[i];note1[i]:=note1[j];note1[j]:=t;end;
for i:=1 to m do
writeln(note1[i].x0,' ',note1[i].y0);
end;
begin
init;
if f=2 then work2 else work1;
end.