import java.util.* ;
import java.lang.* ;
import java.io.* ;
class Ideone
{
{
int n = 8 ;
Scanner in
= new Scanner
( System .
in ) ; int [ ] [ ] a = new int [ n] [ n] ;
int q=- 1 ,p=- 1 ;
for ( int i= 0 ; i< n; i++ ) {
for ( int j= 0 ; j< n; j++ ) {
a[ i] [ j] = in.nextInt ( ) ;
if ( a[ i] [ j] == 1 ) { q= i; p= j; }
}
}
if ( q!=- 1 && p!=- 1 ) {
for ( int i= q; i>= 0 ; i-- ) {
if ( a
[ i
] [ p
] == 2 ) { System .
out .
printf ( "Король под угрозой от ферзя (%d,%d)\n " ,i
+ 1 ,p
+ 1 ) ; break ; } } for ( int i= q; i< n; i++ ) {
if ( a
[ i
] [ p
] == 2 ) { System .
out .
printf ( "Король под угрозой от ферзя (%d,%d)\n " ,i
+ 1 ,p
+ 1 ) ; break ; } } for ( int j= p; j>= 0 ; j-- ) {
if ( a
[ q
] [ j
] == 2 ) { System .
out .
printf ( "Король под угрозой от ферзя (%d,%d)\n " ,q
+ 1 ,j
+ 1 ) ; break ; } } for ( int j= p; j< n; j++ ) {
if ( a
[ q
] [ j
] == 2 ) { System .
out .
printf ( "Король под угрозой от ферзя (%d,%d)\n " ,q
+ 1 ,j
+ 1 ) ; break ; } }
for ( int i= q,j= p; ( i>= 0 && j>= 0 ) ; i-- , j-- ) {
if ( a
[ i
] [ j
] == 2 ) { System .
out .
printf ( "Король под угрозой от ферзя (%d,%d)\n " ,i
+ 1 ,j
+ 1 ) ; break ; } } for ( int i= q,j= p; ( i< n && j< n) ; i++ , j++ ) {
if ( a
[ i
] [ j
] == 2 ) { System .
out .
printf ( "Король под угрозой от ферзя (%d,%d)\n " ,i
+ 1 ,j
+ 1 ) ; break ; } } for ( int i= q,j= p; ( i>= 0 && j< n) ; i-- , j++ ) {
if ( a
[ i
] [ j
] == 2 ) { System .
out .
printf ( "Король под угрозой от ферзя (%d,%d)\n " ,i
+ 1 ,j
+ 1 ) ; break ; } } for ( int i= q,j= p; ( i< n && j>= 0 ) ; i++ , j-- ) {
if ( a
[ i
] [ j
] == 2 ) { System .
out .
printf ( "Король под угрозой от ферзя (%d,%d)\n " ,i
+ 1 ,j
+ 1 ) ; break ; } } }
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJaW50IG4gPSA4OwoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludFtdW10gYSA9IG5ldyBpbnRbbl1bbl07CgkJaW50IHE9LTEscD0tMTsKCQlmb3IgKGludCBpPTA7IGk8bjsgaSsrKXsKCQkJZm9yIChpbnQgaj0wOyBqPG47IGorKyl7CgkJCQlhW2ldW2pdPWluLm5leHRJbnQoKTsKCQkJCWlmIChhW2ldW2pdID09IDEpIHtxPWk7IHA9ajt9CgkJCX0KCQl9CgkJaWYgKHEhPS0xICYmIHAhPS0xKXsKCQkJZm9yIChpbnQgaT1xOyBpPj0wOyBpLS0pIHsKCQkJCWlmIChhW2ldW3BdPT0yKSB7U3lzdGVtLm91dC5wcmludGYoItCa0L7RgNC+0LvRjCDQv9C+0LQg0YPQs9GA0L7Qt9C+0Lkg0L7RgiDRhNC10YDQt9GPICglZCwlZClcbiIsaSsxLHArMSk7YnJlYWs7fX0KCQkJZm9yIChpbnQgaT1xOyBpPG47IGkrKykgewoJCQkJaWYgKGFbaV1bcF09PTIpIHtTeXN0ZW0ub3V0LnByaW50Zigi0JrQvtGA0L7Qu9GMINC/0L7QtCDRg9Cz0YDQvtC30L7QuSDQvtGCINGE0LXRgNC30Y8gKCVkLCVkKVxuIixpKzEscCsxKTticmVhazt9fQoJCQlmb3IgKGludCBqPXA7IGo+PTA7IGotLSkgewoJCQkJaWYg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