#include <bits/stdc++.h>
using namespace std;
string ending(int x)
{
	x%=100;
	if(x/10==1) return "th";
	if(x%10==1) return "st";
	if(x%10==2) return "nd";
	if(x%10==3) return "rd";
	return "th";
}
const string c="Wrong answer! [%d out of %d numbers incorrect (first at %d%s, expected %d, found %d)]";
ifstream in;
ofstream out;
int read()
{
	int x;
	in>>x;
	return x;
}
int main()
{
	in.open("input");
	out.open("score.txt");
	ios::sync_with_stdio(0);
	int k=read(),q=read();
	cout<<k<<' '<<q<<endl;
	int p=q;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
			cout<<read()<<' ';
		cout<<endl;
	}
	int wa=0,wp=0,we=0,wr=0;
	while(q--)
	{
		cout<<read()<<' '<<read()<<endl;
		int an=read();
		int get;
		cin>>get;
		if(an!=get)
		{
			wa++;
			if(wa==1) wp=p-q,we=an,wr=get;
		}
	}
	freopen("score.txt","w",stdout);
	if(wa)
	{
		fprintf(stderr,c.c_str(),wa,p,wp,ending(wp).c_str(),we,wr);
		out<<0<<endl;
		return 0;
	}
	fprintf(stderr,"Accepted! [%d numbers]",p);
	out<<100<<endl;
	return 0;
}
