Help me in solving NCOPIES problem

My issue

My code

#include <iostream>
using namespace std;

int main() {
	
	int t;
	int N,M;
	bool A;
	while(t--)
	{
	    cin>>N>>M;
	    cout<<endl;
	    cin>>A;
	    if()
	}
	return 0;
}

Problem Link: NCOPIES Problem - CodeChef