See the problem statement here: [http://codeforces.com/contest/921/problem/01](//codeforces.com/contest/921/problem/01).
none
none
def bfs(walls, doors, keys, exits, x, y, a, b, n, m):
    dist = [[1000000000] * m for i in range(n)]
    dist[a][b] = 0
    queue = [(a, b)]
    used = set()
    dx = [1, 0, 0, -1]
    dy = [0, 1, -1, 0]
    while queue:
        (cur_x, cur_y) = queue.pop(0)
        if (cur_x, cur_y) not in used:
            used.add((cur_x, cur_y))
            for i in range(4):
                new_x, new_y = cur_x + dx[i], cur_y + dy[i]
                if 0 <= new_x < n and 0 <= new_y < m:
                    if (new_x, new_y) not in used:
                        if (cur_x, cur_y, new_x, new_y) not in walls:
                            if (new_x, new_y, cur_x, cur_y) not in walls:
                                if (cur_x, cur_y, new_x, new_y) not in doors:
                                    if (new_x, new_y, cur_x, cur_y) not in doors:
                                        queue.append((new_x, new_y))
                                        dist[new_x][new_y] = dist[cur_x][cur_y] + 1
    return dist                                    

def restore(dist, x, y, n, m):
    if dist[x][y] == 0:
        return ""
    dx = [1, 0, 0, -1]
    dy = [0, 1, -1, 0]
    prt = ["move-down\n", "move-right\n", "move-left\n", "move-up\n"]
    for i in range(4):
        new_x, new_y = x + dx[i], y + dy[i]
        if 0 <= new_x < n and 0 <= new_y < m:
            if dist[x][y] - 1 == dist[new_x][new_y]:
                return prt[i] + restore(dist, new_x, new_y, n, m)

(g, w, n, m, x, y, c, d, k, e) = map(int, input().split())

walls = set()

for i in range(c):
    (x1, y1, x2, y2) = map(int, input().split())
    walls.add((x1, y1, x2, y2))

doors = set()

for i in range(d):
    (x1, y1, x2, y2) = map(int, input().split())
    doors.add((x1, y1, x2, y2))

keys = set()

for i in range(k):
    (x1, y1) = map(int, input().split())
    keys.add((x1, y1))

exits = set()

for i in range(e):
    (x1, y1) = map(int, input().split())
    exits.add((x1, y1))

best_len = 141928123080123
best = ""
for (a, b) in exits:
    dist = bfs(walls, doors, keys, exits, x, y, a, b, n, m)
    ans = restore(dist, x, y, n, m)
    if len(ans) < best_len:
        best = ans
        best_len = len(ans)
print(best) 