n, p = map(int, input().split())
x, y = map(int, input().split())
direction = input()
match direction:
case "N":
step_x, step_y = -1, 0
case "S":
step_x, step_y = 1, 0
case "W":
step_x, step_y = 0, -1
case "E":
step_x, step_y = 0, 1
case "NE":
step_x, step_y = -1, 1
case "SE":
step_x, step_y = 1, 1
case "SW":
step_x, step_y = 1, -1
case "NW":
step_x, step_y = -1, -1
new_x = (x + p * step_x) % n
new_y = (y + p * step_y) % n
new_x = new_x if new_x >= 0 else new_x + n
new_y = new_y if new_y >= 0 else new_y + n
print(new_x, new_y)