from collections import deque n, k = int(input()), int(input()) board = [[0] * n for _ in range(n)] for _ in range(k): x, y = map(int, input().split()) board[x - 1][y - 1] = 1 dx, dy = [0, 1, 0, -1], [1, 0, -1, 0] d, time = 0, 1 snake = deque([[0, 0]]) x, y = 0, 0 l = int(input()) rule = deque([input().split() for _ in range(l)]) while True: x, y = x + dx[d], y + dy[d] if [x, y] in snake or x in..