#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include "testlib.h"

using namespace std;

#define VI vector<int>

#define FOR(i,n) for (int i = 0; i < (int)(n); i++)

#define PB push_back
#define SZ(a) a.size()
#define MP make_pair
#define PII pair<int, int>
#define VI vector<int>
#define VVI vector<VI >
#define PII pair<int, int>

int n, res;

vector<string> ja, oa;

vector<int> a;

int main(int argc, char *argv[])
{
	registerTestlibCmd(argc, argv);

	n = inf.readInt();
	cout<<n<<endl;
	while (!inf.eof() && ja.size() < n)
	{
		ja.push_back(inf.readWord());
		//cout<<ja.back()<<endl;
	}

	while (!ouf.eof() && oa.size() < n)
	{
		oa.push_back(ouf.readWord());
		int v;
		sscanf(oa.back().c_str(), "%d", &v);
		a.push_back(v);
		//cout<<oa.back()<<endl;
	}

	if (ja[0] == "impossible")
	{
		if (oa[0] != "impossible")
			quitf(_wa, "Expected impossible, but answer was found");
		quitf(_ok, "Impossible");
	}
	if (ja.size() != oa.size())
		quitf(_wa, "Wrong sequence length");

	sort(oa.begin(), oa.end());
	sort(ja.begin(), ja.end());
	for (int i = 0; i < oa.size(); i++)
		if (oa[i] != ja[i])
			quitf(_wa, "Wrong sequence");

	for (int i = 0; i < a.size() - 1; i++)
		if (((a[i] + a[i+1]) % 3) == 0)
			quitf(_wa, "Wrong neighbours %d and %d at position %d", a[i], a[i+1], i);

	quitf(_ok, "OK %d", n);
}
