#!/usr/bin/python3 # Zkopírovaný solver z 29-Z2-1, doplněný o překážky P, N = (int(x) for x in input().split()) obstacles = set(tuple(int(x) for x in input().split()) for _ in range(P)) commands = input() # position = (0, 0) orientation_index = 0 orientations = [(0, 1), (-1, 0), (0, -1), (1, 0)] hit = 0 def sum_coords(a, b): xa, ya = a xb, yb = b return (xa + xb, ya + yb) #Po jednom zpracujeme každý příkaz `c` for c in commands: # Pokud je příkaz `>`, tak se v poli orientací posuneme o jedna zpátky if c == '>' : orientation_index = (orientation_index - 1) % 4 # Pokud je příkaz `>`, tak se v poli orientací posuneme o jedna dál elif c == '<' : orientation_index = (orientation_index + 1) % 4 # Pokud je příkaz `A`, tak si zjistíme, jaký posun odpovídá aktuální orientaci a aplikujeme ho na naše souřadnice elif c == 'A' : pos = sum_coords(position, orientations[orientation_index]) if pos in obstacles: hit += 1 else: position = pos final_x, final_y = position print(str(final_x) + " " + str(final_y)) print(hit)