// Andrei
Bordeianu
// Elena Cuza NC
of Bucharest
// Senior/3
#include
<iostream>
#include
<fstream>
#include
<iomanip>
#include
<cmath>
using namespace
std;
int a[20][5], m,
n, lin, col, k, l;
ifstream in
("input.txt");
ofstream out
("output.txt");
int main () {
for (lin=1; lin<=5; lin++) {
col=1;
in >> a[col][1] >>
a[col][2];
while (a[col][1] != 0) {
col ++;
in >> a[col][1] >>
a[col][2];
}
for (k=1; k<=8; k++) {
for (l=1; l<=8; l++) {
n = 0;
for (m=1; m<col; m++)
if ( a[m][1]==k ||
a[m][2]==l || abs(k-a[m][1]) == abs(l-a[m][2]) )
n++;
if (n == col-1) {
out << k << ", " << l << endl;
break;
}
}
if (n==col-1)
break;
}
}
return 0;
}