#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
#define N 8
int row[N],col[N],dpos[N*2-1],dneg[N*2-1];
bool X[N][N];

void print()
{
	REP(i,N)
	{
		REP(j,N)
		{
			if(X[i][j])
			{
				if(row[i]!=j)return ;
			}
		}
	}
	REP(i,N)
	{
		REP(j,N)
		{
			cout<<((row[i]==j)?"Q":".");
		}
		cout<<endl;
	}
}

void recursive(int i)
{
	if(i==N)
	{
		print();
		return;
	}
	
	REP(j,N)
	{
		if(col[j]+dpos[i+j]+dneg[i-j+N-1]!=0)continue;
		row[i]=j;col[j]|=1;dpos[i+j]|=1;dneg[i-j+N-1]|=1;
		recursive(i+1);
		row[i]^=row[i];col[j]^=col[j];dpos[i+j]^=dpos[i+j];dneg[i-j+N-1]^=dneg[i-j+N-1];
	}
}
int main()
{
	int k;
	scanf("%d",&k);
	REP(i,k)
	{
		int r,c;
		scanf("%d%d",&r,&c);
		X[r][c]=true;
	}
	recursive(0);
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=305;
int n,a[N<<1][N<<1];
void hf(int x,int de){
	int t=0;
	while(x%4==0){x/=4; t++;}
	if(x%4==2){
		For(i,0,2*n-1){
			For(j,0,2*n-1)if(i>>t&1)a[i][j]|=de;
		}
	}else {
		For(i,0,2*n-1){
			For(j,0,2*n-1)if(((i>>t)+(j>>t))&1)a[i][j]|=de;
		}
	}
}
vector<PI> v[4];
int main(){
	n=read(); int d1=read(),d2=read();
	hf(d1,1);
	hf(d2,2);
	For(i,0,2*n-1)For(j,0,2*n-1)v[a[i][j]].pb(mp(i,j));
	For(i,0,3)if(v[i].size()>=n*n){
		For(j,0,n*n-1)wri(v[i][j].fi),writeln(v[i][j].se); return 0;
	}
}