#!/usr/bin/python3 # Načtení vstupu. pos = tuple(map(int, input().split())) box_pos = tuple(map(int, input().split())) directions = input() assert len(pos) == 2 assert len(box_pos) == 2 def apply(pos: tuple[int, int], move: tuple[int, int]) -> tuple[int, int]: """Změna pozice v jednom tahu.""" return pos[0] + move[0], pos[1] + move[1] # Přepočet směrů na změnu souřadnic. moves = {"P": (1, 0), "L": (-1, 0), "N": (0, 1), "D": (0, -1)} # Simulace pohybu buldozeru. for direction in directions: delta = moves[direction] pos = apply(pos, delta) # Pokud je buldozer na stejné pozici jako krabice, tak ji posune. if pos == box_pos: box_pos = apply(box_pos, delta) # Vypsání výstupu. print(pos[0], pos[1]) print(box_pos[0], box_pos[1])