#include <iostream>
#define SIZE 8

void threaten(int board[][SIZE], int x, int y)
{
	for (int i=0; i<SIZE; i++) {
		board[i][y]++; board[x][i]++;
	}
	for (int i=-x; i<SIZE-x; i++) {
		if (0 <= y+i && y+i < SIZE) board[x+i][y+i]++;
		if (0 <= y-i && y-i < SIZE) board[x+i][y-i]++;
	}
	board[x][y]+=100;
}

void unthreaten(int board[][SIZE], int x, int y)
{
	for (int i=0; i<SIZE; i++) {
		board[i][y]--; board[x][i]--;
	}
	for (int i=-x; i<SIZE-x; i++) {
		if (0 <= y+i && y+i < SIZE) board[x+i][y+i]--;
		if (0 <= y-i && y-i < SIZE) board[x+i][y-i]--;
	}
	board[x][y]-=100;
}

bool solve(int board[][SIZE], int rest)
{
	if (rest==0) return true;
	
	for (int i=0; i<SIZE; i++) {
		for (int j=0; j<SIZE; j++) {
			if (board[i][j]>0) continue;
			threaten(board, i, j);
			if (solve(board, rest-1)) return true;
			unthreaten(board, i, j);
		}
	}
	return false;
}

int main()
{
	int board[SIZE][SIZE];
	for (int i=0; i<SIZE; i++) {
		for (int j=0; j<SIZE; j++) board[i][j] = 0;
	}
	
	int k; std::cin >> k;
	for (int i=0; i<k; i++) {
		int x, y;
		std::cin >> x >> y;
		threaten(board, x, y);
	}
	
	solve(board, SIZE-k);
	
	for (int i=0; i<SIZE; i++) {
		for (int j=0; j<SIZE; j++) {
			if (board[i][j] < 100) std::cout << ".";
			else std::cout << "Q";
		}
		std::cout << std::endl;
	}
	
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n;
  cin >> n;
  ll taka = 0,ao = 0;
  priority_queue<Pl> que;
  vector<Pl> v(n);
  rep(i,n){
    ll a,b;cin >> a >> b;
    que.push(make_pair(a+b,i));
    v[i] = make_pair(a,b);
  }
  rep(i,n){
    Pl k = que.top();que.pop();
    if(!(i & 1))taka += v[k.second].first;
    else ao += v[k.second].second;
  }
  cout << taka-ao << endl;
  







  

  return 0;
}