#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "testlib.h"

using namespace std;

const int max_size = 200;

int n, a;
bool used[max_size];

void readtour()
{
    int ps, i;
    for (i = 1; i <= n; i++)
        used[i] = false;
    for (i = 0; i < n; i++)
    {
        ps = inf.readInt();
        if (ps < 0 || ps > n)
            quitf(_pe, "No contestant with number %d", ps);
        if (used[ps])
            quitf(_pe, "Contestant %d meets more than one time", ps);
        if (i < n - 1)
            inf.readSpace();
        used[ps] = true;
    }
    inf.readEoln();
}

int main()
{
    registerValidation();
    n = inf.readInt();
    if (n < 1 || n > max_size)
        quitf(_pe, "1 <= n <= %d", max_size);
    inf.readSpace();
    a = inf.readInt();
    if (a < 1 || a > n)
        quitf(_pe, "Wrong place for Vasya");
    inf.readEoln();
    readtour();
    readtour();
    inf.readEof();

    return 0;
}