#include "casino.h"
#include <iostream>

const std::string PASSWORD = "egoi2026fans";
int n, games;

static void Azzurro_grader(){	
	int length; std::cin >> length; 
	std::string str; std::cin >> str; 
	
	std::vector<std::vector<int>> ret = Azzurro(n, length, str);
	
	if(ret.size() > n){
		ret = std::vector<std::vector<int>>(n, std::vector<int>(n, -1));
	}
	for(int i = 0; i < n; i ++){
		if(ret[i].size() > n){
			ret = std::vector<std::vector<int>>(n, std::vector<int>(n, -1));
		}
	}
	ret.resize(n, std::vector<int>(n, -1));
	for(int i = 0; i < n; i ++){
		ret[i].resize(n, -1);
	}
	std::cout << PASSWORD << std::endl;
	
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < n; j ++){
			std::cout << ret[i][j] << " ";
		} 
		std::cout << std::endl;
	}
}

static void Bordeaux_grader(){
	int length; std::cin >> length; 
	
	std::vector<std::vector<int>> enc(n, std::vector<int>(n, 0));
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < n; j ++){
			std::cin >> enc[i][j];
		}
	}
	
	std::string ret = Bordeaux(n, length, enc);
	
	std::cout << PASSWORD << std::endl;
	std::cout << ret << "L" << std::endl;
	// append a single character to the end of ret
	// to handle the case of the contestant returning
	// an empty string
}

int main(){
	bool self; std::cin >> self;
	std::cin >> games >> n;
	for(int i = 0; i < games; i ++){
		if(self == false) Azzurro_grader();
		else			  Bordeaux_grader();
	}
}
