#include <fstream>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

ifstream fout("pizza.out");
ifstream fin("pizza.in");

int n[3], C, a[3][22], k=0, nmax;

void msg(string mesage,int score)
{
    cout<<score<<' '<<mesage<<'\n';
    fin.close();
    fout.close();
    exit(0);
}

bool ok(int d)//e ok daca avem o coloana descresc. pe tija d
{
    if(n[(d+1)%3]!=0 or n[(d+2)%3]!=0)
        return false;//nu e ok daca sunt elemente pe alte tije
    else
        for(int i=0;i<n[d]-1;i++)
            if(a[d][i]<a[d][i+1])
                return false;// nu e ok daca coloana nu e crescatoare
    return true;
}

int main()
{
    int i,j,x,y,z;
    string mesaj;
    if ( !fout )
        msg("Missing file pizza.out!", 0);
    if ( !fin )
        msg("Missing file pizza.in!", 0);

    for (i=0;i<3;++i)
    {
        fin>>n[i];
        for (j=1;j<=n[i];++j)
            fin>>a[i][j];
    }
    nmax=n[0]+n[1]+n[2];
    fin>>C;
    C--;
    a[1][0]=999998;
    a[2][0]=999999;
    a[0][0]=999997;
    int linia=0;
    while (fout>>x>>y)
    {
        if (x==0 and y==0)
        {
            if (ok(C) and n[C]==nmax)
                msg("OK ",5);
            else
                msg("Missing final result in one column",0);
        }
        linia++;
        if (linia>3000000) {
            mesaj="Too many moves";
            msg(mesaj,0);
        }
        x--;
        y--;
        if (!(x>=0 and x<=2))
        {
            mesaj="Wrong start point";
            msg(mesaj,0);
        }
        if (!(y>=0 and y<=2))
        {
            msg("Wrong end point",0);
        }
        if (n[x]==0)
        {
            msg("empty column for extract boxes",0);
        }
        z=a[x][n[x]];
        a[x][n[x]]=0;
        n[x]--;
        if (!(z<=a[y][n[y]]))
            msg("big box on small box",0);
        a[y][++n[y]]=z;
/*        cout<<x+1<<" "<<y+1<<endl;
        for (i=1;i<=n[0];++i)
            cout<<a[0][i]<<" ";
        cout<<endl;
        for (i=1;i<=n[1];++i)
            cout<<a[1][i]<<" ";
        cout<<endl;
        for (i=1;i<=n[2];++i)
            cout<<a[2][i]<<" ";
        cout<<endl;
        cout<<endl;
*/
    }
    msg("unfinished problem",0);
    return 0;
}
