#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define N 8
int a[N], b[2 * N - 1], c[2 * N - 1], x[N];
int n;
int xp[N], yp[N];

void found() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (x[i] == j) cout << "Q";
			else           cout << ".";
		}
		cout << endl;
	}
}

void try_(int i) {
	for (int j = 0; j < N; j++) {
		if (a[j] && b[i+j] && c[i-j+N-1]) {
			x[i] = j;
			if (i < N -1) {
				a[j] = b[i+j] = c[i-j+N-1] = 0;
				try_(i + 1);
				a[j] = b[i+j] = c[i-j+N-1] = 1;
			}
			else {
				bool flag = true;
				for (int k = 0; k < n; k++)
					if (x[xp[k]] != yp[k])
						flag = false;
				if (flag)
					found();
			}

		}
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> xp[i] >> yp[i];

	fill_n(a, N, 1);
	fill_n(b, 2 * N - 1, 1);
	fill_n(c, 2 * N - 1, 1);
	try_(0);
	return 0;
}