{$R+,Q+}
{$apptype console}

uses
	Testlib, Sysutils;

const
	maxN = 200;

var
	ansK, outK : integer;
	a, o : array[1..maxN,1..maxN] of integer;

	i : integer;
	x, y, tmp : integer;

begin
	ansK := ans.ReadInteger;
	outK := ouf.ReadInteger;

	if outK <> ansK then
		Quit(_WA, 'Wrong number of pairs: ' + inttostr(outK) + ' instead of ' + inttostr(ansK));

	fillchar(a, sizeof(a), 0);
	for i := 1 to ansK do begin
		x := ans.ReadInteger;
		y := ans.ReadInteger;

		if x > y then begin
			tmp := x;
			x := y;
			y := tmp;
		end;

		if (x < 1) or (x > maxN) or (y < 1) or (y > maxN) then
			Quit(_Fail, '');

		inc(a[x,y]);
		if a[x,y] > 1 then
			Quit(_Fail, '');
	end;

	fillchar(o, sizeof(o), 0);
	for i := 1 to outK do begin
		x := ouf.ReadInteger;
		y := ouf.ReadInteger;

		if x > y then begin
			tmp := x;
			x := y;
			y := tmp;
		end;

		if (x < 1) or (x > maxN) or (y < 1) or (y > maxN) then
			Quit(_WA, 'Pair #' + inttostr(i) + ' is invalid');

		inc(o[x,y]);
		if o[x,y] > 1 then
			Quit(_WA, 'Duplicate pair {' + inttostr(x) + ',' + inttostr(y) + '} found');
	end;

	for x := 1 to maxN do
		for y := 1 to maxN do
			if o[x,y] <> a[x,y] then
				Quit(_WA, 'Mismatch at pair {' + inttostr(x) + ',' + inttostr(y) + '}');

	Quit(_OK, format('%d pairs', [outK]));
end.
