m,n = map(int,input().strip().split())
a = [list(map(int,input().strip().split())) for i in range(m)]
x,y,s,k = input().strip().split()
x = int(x)
y = int(y)
k = int(k)
f = ['U','R','D','L']
for i in range(k):
if a[x][y] == 1:
a[x][y] = 0
s = f[(f.index(s)+1) % 4]
else:
a[x][y] = 1
s = f[(f.index(s)+3) % 4]
if s == 'U':
x-=1
elif s == 'D':
x+=1
elif s == 'L':
y-=1
else:
y+=1
print('{} {}'.format(x,y))
0.0分
0 人评分