//Checker Задачи ДВЕ ДОМИНОШКИ.

#include "testlib.h"
using namespace std;
int a[4], b[4];
int x[7], y[7];

int main(int argc, char *argv[])
{ setName("Two-dominoes checker");
    registerTestlibCmd(argc, argv);
    
    int ja = ans.readInt();
      b[0] = ouf.readInt(-1, 6);
    if ((b[0] == -1) && (ja == -1)) quitf(_ok, "");
    if ((b[0] == -1) && (ja != -1)) quitf(_wa, "expected %d, found %d", ja, b[0]);
    if ((b[0] != -1) && (ja == -1)) quitf(_wa, "expected %d, found %d", ja, b[0]);

    for (int i = 0; i < 4; i++)  a[i] = inf.readInt();
	for (int i = 1; i < 4; i++)  b[i] = ouf.readInt(0, 6);

    for (int i = 0; i < 4; i++)
    {	x[a[i]]++;  y[b[i]]++;}
    
    for (int i = 0; i < 7; i++)
    	 if (x[i] != y[i]) quitf(_wa, "invalid numbers in answer ");
    
    if (b[1] != b[2]) quit(_wa, "This is bad connection dominoes");
    quitf(_ok, "");
}