#!/usr/bin/python3 import collections import sys try: N = int(input()) start = tuple(int(x) for x in input().split()) if len(start) != 2 or not (0 <= start[0] < N and 0 <= start[1] < N): raise ValueError end = tuple(int(x) for x in input().split()) if len(end) != 2 or not (0 <= end[0] < N and 0 <= end[1] < N): raise ValueError moves = int(input()) moves = [tuple(int(x) for x in input().split()) for _ in range(moves)] if any(map(lambda x: len(x) != 2, moves)): raise ValueError; except ValueError: print("Vstup ma spatny format.",file=sys.stderr) exit(1) except EOFError: print("Vstup predcasne skoncil.",file=sys.stderr) exit(1) board = {start: start} queue = collections.deque([start]) while len(queue) > 0: x0, y0 = pos0 = queue.popleft() for x, y in moves: x, y = pos = x0+x, y0+y if not (0 <= x < N and 0 <= y < N): continue if pos not in board: board[pos] = pos0 queue.append(pos) if pos == end: break else: continue break if end not in board: print("Cil je nedosazitelny.",file=sys.stderr) exit(1) prev = board[pos] backtrack = [] while prev != start: backtrack.append(prev) prev = board[prev] print(len(backtrack)+1) for i in reversed(backtrack): print(*i)