#include <iostream>
#include <vector>
#include <utility>

using namespace std;


int main()
{
    int x, y, a, b, c, d, j, m, v;
    vector<pair<int, int> > ladder;
    cin >> x >> y;
    for (int i = 0; i < x; i++) {
        cin >> a >> b;
        ladder.emplace_back(a, b);
    }
    vector<pair<int, int> > snake;
    for (int i = 0; i < y; i++) {
        cin >> c >> d;
        snake.emplace_back(c, d);
    }
    vector<int> moves;
    cin >> v;
    while (v != 0) {
        moves.push_back(v);
        v = 0;
        cin >> v;
    }
    return 0;
}