var n,k,i,j,x,y:longint;
ch:char;
dx,dy:array[1..10000000]of longint;
a:array[1..1000,1..1000]of longint;
s:ansistring;
procedure swap(var a,b:longint);
var t:longint;
begin
t:=a; a:=b; b:=t;
end;
begin
readln(n,k);
for i:=1 to n do begin
for j:=1 to n do begin
read(a[i,j]);
dx[i]:=i;
dy[j]:=j;
end;
readln;
end;
for i:=1 to k do begin
readln(s);
ch:=s[1];
delete(s,1,2);
val(copy(s,1,pos(' ',s)-1),x);
delete(s,1,pos(' ',s));
val(s,y);
if ch='R' then swap(dx[x],dx[y])
else if ch='C' then swap(dy[x],dy[y])
else if ch='A' then writeln(a[dx[x],dy[y]]);
end;
close(input);
close(output);
end.