uses
	testlib, sysutils;
const
	maxn = 1000;
var
	jc, pc: longint;
	jt, pt: longint;
	ja, pa: array [1..maxn] of string;
	i: longint;
begin
	jc := ans.readlongint;
	jt := ans.readlongint;

	for i := 1 to jc do begin
		ja[i] := ans.readword(blanks, blanks);
	end;

	pc := ouf.readlongint;
	pt := ouf.readlongint;

	if (jc <> pc) or (jt <> pt) then
		quit(_wa, format('expected: %d, %d; found: %d, %d', [jc, jt, pc, pt]));

	for i := 1 to pc do begin
		pa[i] := ouf.readword(blanks, blanks);
		if pa[i] <> ja[i] then
			quit(_wa, format('addict %d wrong, expected: %s, found: %s', [i, ja[i], pa[i]]));
	end;

	quit(_ok, format('%d %d', [jc, jt]));
end.