See the problem statement here: [http://codeforces.com/contest/921/problem/01](//codeforces.com/contest/921/problem/01).
none
none
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>

#define d(x) cerr << #x << ": " << x << endl;

using namespace std;

typedef long long ll;
typedef long double ld;

template<class T> ostream& operator<<(ostream& os, vector<T>& v) {for (auto i : v) os << i << " "; return os;}
template<class T> ostream& operator<<(ostream& os, set<T>& v) {for (auto i : v) os << i << " "; return os;}
template<class T, class R> ostream& operator<<(ostream& os, pair<T, R>& v) {os << '(' << v.first << ' ' << v.second << ')' << ' '; return os;}

int getType(int x, int y, int xx, int yy) {
    if (xx - x == 1) return 2;
    if (x - xx == 1) return 0;
    if (yy - y == 1) return 1;
    if (y - yy == 1) return 3;
}

int n, m;

pair<int, int> check(int x, int y, int type) {
    if (type == 0) {
        x--;
    } else if (type == 1) {
        y++;
    } else if (type == 2) {
        x++;
    } else if (type == 3) {
        y--;
    }
    if (x >= 0 && x < n && y >= 0 && y < m) {
        return {x, y};
    } else {
        return {-1, -1};
    }
}

void dfs(int x, int y, vector<vector<vector<bool>>>& gr, vector<vector<bool>>& exits, vector<vector<bool>>& used, vector<int>& kek, int from) {
    used[x][y] = true;
    if (!kek.empty() || exits[x][y] == true) {
        kek.push_back(from);
        return;
    }
    for (int i = 0; i < 4; ++i) {
        if (gr[x][y][i] == true) {
            auto nw = check(x, y, i);
            if (nw.first == -1) continue;
            if (!used[nw.first][nw.second]) {
                dfs(nw.first, nw.second, gr, exits, used, kek, i);
                if (!kek.empty()) {
                    kek.push_back(from);
                    return;
                }
            }
        }
    }
}

int main() {
    // freopen("input-3.txt", "r", stdin);
    // freopen("robot.abc", "w", stdout);


    int num, w, x, y, c, d, k, e;
    cin >> num >> w >> n >> m >> x >> y >> c >> d >> k >> e;
    vector<vector<vector<bool>>> gr(n, vector<vector<bool>>(m, vector<bool>(4, true)));
    vector<vector<bool>> exits(n, vector<bool>(m, false));
    for (int i = 0; i < c; ++i) {
        int xx, xxx, yy, yyy;
        cin >> xx >> yy >> xxx >> yyy;
        gr[xx][yy][getType(xx, yy, xxx, yyy)] = false;
        gr[xxx][yyy][getType(xxx, yyy, xx, yy)] = false;
    }
    for (int i = 0; i < d; ++i) {
        int xx, xxx, yy, yyy;
        cin >> xx >> yy >> xxx >> yyy;
        gr[xx][yy][getType(xx, yy, xxx, yyy)] = false;
        gr[xxx][yyy][getType(xxx, yyy, xx, yy)] = false;
    }
    for (int i = 0; i < k; ++i) {
        int xx, yy;
        cin >> xx >> yy;
    }
    for (int i = 0; i < e; ++i) {
        int xx, yy;
        cin >> xx >> yy;
        exits[xx][yy] = true;
    }
    vector<vector<bool>> used(n, vector<bool>(m, false));
    vector<int> kek;
    dfs(x, y, gr, exits, used, kek, 0);
    // d("kek");
    for (int i = kek.size() - 1; i >= 0; --i) {
        cout << "move-";
        if (kek[i] == 0) {
            cout << "up";
        } else if (kek[i] == 1) {
            cout << "right";
        } else if (kek[i] == 2) {
            cout << "down";
        } else if (kek[i] == 3) {
            cout << "left";
        }
        cout << "\n";
    }
}