uses
	testlib, sysutils, math;

const
	maxn = 50;

var
	ja, pa, s: string;
	z: int64;
	a, b: array [1..maxn] of int64;
	t: longint;
	i, n: longint;
	maxbits: longint;

function countones(z: int64): longint;
var
	r: longint;
begin
	r := 0;

	while (z > 0) do begin
		if z mod 2 = 1 then
			inc(r);
		z := z div 2;
	end;

	countones := r;
end;

function countbits(z: int64): longint;
var
	r: longint;
begin
	r := 0;

	while (z > 0) do begin
		inc(r);
		z := z div 2;
	end;

	countbits := r;
end;

begin
	ja := ans.readstring;
	pa := ouf.readstring;

	if pa = 'impossible' then begin
		if ja = 'impossible' then
			quit(_ok, 'impossible');
		quit(_wa, 'impossible unexpected');
	end;

	ouf.reset;

	n := inf.readlongint;
	maxbits := 0;
	for i := 1 to n do begin
		s := inf.readword(blanks, blanks);
		val(s, a[i], t);
		maxbits := max(maxbits, countbits(a[i]));
	end;

	z := 0;
	for i := 1 to n do begin
		s := ouf.readword(blanks, blanks);
		val(s, b[i], t);
		if (t <> 0) then
			quit(_pe, format('number expected, %s found', [s]));
		if (b[i] <= 0) then
			quit(_wa, format('positive number expected, %s found', [s]));
		if countbits(b[i]) > maxbits then
			quit(_wa, format('%d cannot be obtained from %d by bit rearrangement - too large', [b[i], a[i]]));
		if countones(b[i]) <> countones(a[i]) then
			quit(_wa, format('%d cannot be obtained from %d by bit rearrangement', [b[i], a[i]]));
		z := z xor b[i];
	end;

	if z <> 0 then
		quit(_wa, 'xor is not equal to 0');

	if ja = 'impossible' then
		quit(_fail, 'impossible expected');

	quit(_ok, '');
end.
	