#include<bits/stdc++.h>
using namespace std;
char s[10][10];
int z[10][10];
int n;
char paallac, edessac, takanac, alhaallac, vasemmallac, oikeallac;
int paalla, edessa, takana, alhaalla, vasemmalla, oikealla;
bool samat(vector<int> a, vector<int> b){
for(int i = 0; i < a.size(); i++){
if(a[i] != b[i]) return false;
}
return true;
}
vector<int> rotatex(vector<int> a1){
return {a1[0], a1[3], a1[1], a1[4], a1[2], a1[5]};
}
vector<int> rotatey(vector<int> a1){
return {a1[1], a1[5], a1[2], a1[3], a1[0], a1[4]};
}
bool tarkista(vector<int> a, vector<int> b){
for(int k = 0; k < 4; k++){
for(int j = 0; j < 4; j++){
for(int i = 0; i < 4; i++){
if(samat(a, b)) return 1;
a = rotatex(a);
}
a = rotatey(a);
}
a = rotatex(a);
}
return 0;
}
vector<vector<int>> vastaukset;
int main(){
cin >> n;
int countteri = 0;
for(int ss = 0; ss < n; ss++){
for(int i = 1; i <= 5; i++){
for(int j = 1; j <= 5; j++){
cin >> s[i][j];
}
}
for(int i = 0; i <= 6; i++){
s[i][0] = '.';
s[0][i] = '.';
s[i][6] = '.';
s[6][i] = '.';
}
for(int i = 0; i <= 6; i++){
for(int j = 0; j <= 6; j++){
// cout << s[i][j];
}
// cout << "\n";
}
int x,y;
for(int i = 1; i <= 5; i++){
for(int j = 1; j <= 5; j++){
if(s[i][j] != '.'){
int a = 0;
a += s[i-1][j] != '.';
a += s[i+1][j] != '.';
a += s[i][j+1] != '.';
a += s[i][j-1] != '.';
if( a >= 3){
y = i;
x = j;
}
}
}
}
// cout << y << " " << x << "\n";
int a = 0;
int b = 0;
if(s[y-1][x] != '.' && s[y+1][x] != '.' && s[y][x-1]!= '.' && s[y][x+1] != '.'){
a++;
// NELJÄLLÄ PUOLELLA
if(s[y-2][x] != '.'){
/* .
.
...
.
*/
paallac = s[y-2][x];
edessac = s[y-1][x];
takanac = s[y+1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+2][x] != '.'){
/*
.
...
.
.
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x+2] != '.'){
/*
.
....
.
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x-2] != '.'){
/*
.
....
.
*/
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}
}
else if(s[y-1][x] != '.' && s[y+1][x] != '.' && s[y][x-1] != '.'){
a++;
// YLHÄÄLLÄ, ALHAALLA, VASEMMALLA
/*
.....
..1..
.1A..
..1..
.....
*/
if(s[y-1][x+1] != '.'){
/*
.....
..11.
.1A..
..1..
.....
*/
if(s[y+2][x] != '.'){
/*
.....
..11.
.1A..
..1..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y-1][x+1];
b++;
}else if(s[y-2][x+1] != '.'){
/*
...1.
..11.
.1A..
..1..
.....
*/
paallac = s[y-2][x+1];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y-1][x+1];
b++;
}else if(s[y-1][x+1] != '.'){
}else if(s[y][x-2] != '.'){
/*
.....
..11.
11A..
..1..
.....
*/
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y-1][x+1];
b++;
}else if(s[y-2][x] != '.'){
/*
..1..
..11.
.1A..
..1..
.....
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y-1][x+1];
b++;
}
}else if(s[y+1][x+1] != '.'){
/*
.....
..1..
.1A..
..11.
.....
*/
if(s[y+1][x+2] != '.'){
}else if(s[y+2][x+1] != '.'){
/*
.....
..1..
.1A..
..11.
...1.
*/
paallac = s[y+1][x+1];
edessac = s[y+1][x];
takanac = s[y][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y+2][x+1];
b++;
}else if(s[y+2][x] != '.'){
/*
.....
..1..
.1A..
..11.
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y+1][x+1];
b++;
}else if(s[y][x-2] != '.'){
/*
.....
..1..
11A..
..11.
.....
*/
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y+1][x+1];
b++;
}else if(s[y+2][x] != '.'){
/*
..1..
..1..
.1A..
..11.
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y+1][x+1];
b++;
}
}
if(s[y-2][x] != '.'){
/*
..1..
..1..
.1A..
..1..
.....
*/
if(s[y-2][x+1] != '.'){
/*
..11.
..1..
.1A..
..1..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y-2][x+1];
b++;
}else if(s[y-1][x+1]!= '.'){
/*
..1..
..11.
.1A..
..1..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y-1][x+1];
b++;
}else if(s[y][x+1] != '.'){
/*
..1..
..1..
.1A1.
..1..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+1][x+1] != '.'){
/*
..1..
..1..
.1A..
..11.
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y+1][x+1];
b++;
}else if(s[y+2][x] != '.'){
}else if(s[y][x-2] != '.'){
}
}else if(s[y+2][x] != '.'){
/*
.....
..1..
.1A..
..1..
..1..
*/
if(s[y-2][x] != '.'){
}else if(s[y+2][x+1] != '.'){
/*
.....
..1..
.1A..
..1..
..11.
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y+2][x+1];
b++;
}else if(s[y+1][x+1] != '.'){
/*
.....
..1..
.1A..
..11.
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y+1][x+1];
b++;
}else if(s[y][x+1] != '.'){
/*
.....
..1..
.1A1.
..1..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-1][x+1] != '.'){
/*
.....
..11.
.1A..
..1..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y-1][x];
b++;
}else if(s[y][x-2] != '.'){
}
}else if(s[y][x-2] != '.'){
/*
.....
..1..
11A..
..1..
.....
*/
if(s[y-2][x] != '.'){
}else if(s[y-1][x+1] != '.'){
/*
.....
..11.
11A..
..1..
.....
*/
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y-1][x+1];
b++;
}else if(s[y][x+1] != '.'){
/*
.....
..1..
11A1.
..1..
.....
*/
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+1][x+1] != '.'){
/*
.....
..1..
11A..
..11.
.....
*/
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+2][x] != '.'){
}else if(s[y][x-3] != '.'){
}
}
}else if(s[y-1][x] != '.' && s[y+1][x] != '.' && s[y][x+1] != '.'){
/*
.....
..1..
..A1.
..1..
.....
*/
if(s[y-1][x-1] != '.'){
/*
.....
.11..
..A1.
..1..
.....
*/
if(s[y-1][x-2] != '.'){
}else if(s[y-2][x-1] != '.'){
/*
.1...
.11..
..A1.
..1..
.....
*/
paallac = s[y-2][x-1];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y-1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-2][x] != '.'){
/*
..1..
.11..
..A1.
..1..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y-1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x+2] != '.'){
/*
.....
.11..
..A11
..1..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y-1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+2][x] != '.'){
/*
.....
.11..
..A1.
..1..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y-1][x-1];
oikeallac = s[y][x+1];
b++;
}
}else if(s[y+1][x-1] != '.'){
/*
.....
..1..
..A1.
.11..
.....
*/
if(s[y-1][x] != '.'){
/*
..1..
..1..
..A1.
.11..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y+1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x+2] != '.'){
/*
.....
..1..
..A11
.11..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y+1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+2][x] != '.'){
/*
.....
..1..
..A1.
.11..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y+1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+2][x+1] != '.'){
/*
.....
..1..
..A1.
.11..
.1...
*/
paallac = s[y+2][x-1];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y+1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+1][x+2] != '.'){
}
}else if(s[y][x+2] != '.'){
/*
.....
..1..
..A11
..1..
.....
*/
if(s[y-2][x] != '.'){
}else if(s[y-1][x-1] != '.'){
/*
.....
.11..
..A11
..1..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y-1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+1][x-1] != '.'){
/*
.....
..1..
..A11
.11..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y+1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x+3] != '.'){
/*
......
..1...
..A111
..1...
......
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x+3];
oikeallac = s[y][x+1];
b++;
}else if(s[y+2][x] != '.'){
}else if(s[y][x-1] != '.'){
/*
.....
..1..
.1A11
..1..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}
}else if(s[y+2][x] != '.'){
/*
.....
..1..
..A1.
..1..
..1..
*/
if(s[y+2][x-1] != '.'){
/*
.....
..1..
..A1.
..1..
.11..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y+2][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+1][x-1] != '.'){
/*
.....
..1..
..A1.
.11..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y+1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x-1]!= '.'){
/*
.....
..1..
.1A1.
..1..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-1][x-1] != '.'){
/*
.....
.11..
..A1.
..1..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y-1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x+2]!= '.'){
}
}else if(s[y-2][x] != '.'){
/*
..1..
..1..
..A1.
..1..
.....
*/
if(s[y-2][x-1] != '.'){
/*
.11..
..1..
..A1.
..1..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y-2][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-1][x-1] != '.'){
/*
..1..
.11..
..A1.
..1..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y-1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x-1] != '.'){
/*
..1..
..1..
.1A1.
..1..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+1][x-1] != '.'){
/*
..1..
..1..
..A1.
.11..
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y+1][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x+2] != '.'){
}
}
}
else if(s[y-1][x] != '.' && s[y][x-1] != '.' && s[y][x+1] != '.'){
a++;
// YLHÄÄLLÄ; VASEMMALLA; OIKEALLA
/*
.....
..1..
.1A1.
.....
.....
*/
if(s[y-2][x] != '.'){
/*
..1..
..1..
.1A1.
.....
.....
*/
if(s[y-3][x] != '.'){
/*
..1..
..1..
..1..
.1A1.
.....
.....
*/
paallac = s[y-2][x];
edessac = s[y-3][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x+2] != '.'){
}else if(s[y][x-2] != '.'){
}else if(s[y+1][x+1] != '.'){
/*
..1..
..1..
.1A1.
...1.
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x+1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+1][x-1] != '.'){
/*
..1..
..1..
.1A1.
.1...
.....
*/
paallac = s[y-2][x];
edessac = s[y+1][x-1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}
}else if(s[y][x-2] != '.'){
/*
.....
..1..
11A1.
.....
.....
*/
if(s[y-2][x] != '.'){
}else if(s[y+1][x-2] != '.'){
/*
.....
..1..
11A1.
1....
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x-2];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+1][x-1] != '.'){
/*
.....
..1..
11A1.
.1...
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x-1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+1][x] != '.'){
/*
.....
..1..
11A1.
..1..
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+1][x+1] != '.'){
/*
.....
..1..
11A1.
...1.
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x+1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}
}else if(s[y][x+2] != '.'){
/*
.....
..1..
.1A11
.....
.....
*/
if(s[y-2][x] != '.'){
}else if(s[y+1][x-1] != '.'){
/*
.....
..1..
.1A11
.1...
.....
*/
b++;
paallac = s[y][x+2];
edessac = s[y+1][x-1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+1][x] != '.'){
/*
.....
..1..
.1A11
..1..
.....
*/
b++;
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+1][x+1] != '.'){
/*
.....
..1..
.1A11
...1.
.....
*/
b++;
paallac = s[y][x+2];
edessac = s[y+1][x+1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+1][x+2] != '.'){
/*
.....
..1..
.1A11
....1
.....
*/
b++;
paallac = s[y][x+2];
edessac = s[y+1][x+2];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}
}else if(s[y+1][x+1] != '.'){
/*
.....
..1..
.1A1.
...1.
.....
*/
b++;
if(s[y-2][x] != '.'){
/*
..1..
..1..
.1A1.
...1.
.....
*/
b++;
paallac = s[y-2][x];
edessac = s[y+1][x+1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y][x-2] != '.'){
/*
.....
..1..
11A1.
...1.
.....
*/
paallac = s[y][x-2];
edessac = s[y+1][x+1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y][x+2] != '.'){
/*
.....
..1..
.1A11
...1.
.....
*/
b++;
paallac = s[y][x+2];
edessac = s[y+1][x+1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+1][x+2] != '.'){
/*
.....
..1..
.1A1.
...11
.....
*/
b++;
paallac = s[y+1][x+2];
edessac = s[y+1][x+1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+2][x+1] != '.'){
/*
.....
..1..
.1A1.
...1.
...1.
*/
b++;
paallac = s[y+2][x+1];
edessac = s[y+1][x+1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}
}else if(s[y+1][x-1] != '.'){
/*
.....
..1..
.1A1.
.1...
.....
*/
if(s[y][x-2] != '.'){
/*
.....
..1..
11A1.
.1...
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x-1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y][x+2] != '.'){
/*
.....
..1..
.1A11
.1...
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x-1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+1][x-2] != '.'){
/*
.....
..1..
.1A1.
11...
.....
*/
b++;
paallac = s[y+1][x-2];
edessac = s[y+1][x-1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+2][x-1] != '.'){
}else if(s[y-2][x] != '.'){
/*
..1..
..1..
.1A1.
.1...
.....
*/
b++;
paallac = s[y-2][x];
edessac = s[y+1][x-1];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}
}
}
else if(s[y+1][x] != '.' && s[y][x-1] != '.' && s[y][x+1] != '.'){
a++;
// ALHAALLA VASEMMALLA OIKEALLA
/*
.....
.....
.1A1.
..1..
.....
*/
if(s[y+2][x] != '.'){
//return 0;
/*
.....
.....
.1A1.
..1..
..1..
*/
if(s[y-1][x] != '.'){
/*
.....
..1..
.1A1.
..1..
..1..
*/
b++;
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y-1][x-1] != '.'){
/*
.....
.1...
.1A1.
..1..
..1..
*/
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x-1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-1][x+1] != '.'){
return 0;
/*
.....
...1.
.1A1.
..1..
..1..
*/
b++;
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x+1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+3][x] != '.'){
/ return 0;
/*
.....
.....
.1A1.
..1..
..1..
..1..
*/
b++;
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y+3][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y][x-2] != '.'){
}else if(s[y][x+2] != '.'){
}
}else if(s[y][x-2] != '.'){
// return 0;
/*
.....
.....
11A1.
..1..
.....
*/
if(s[y-1][x-2] != '.'){
/*
.....
1....
11A1.
..1..
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x-2];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y-1][x-1] != '.'){
/*
.....
.1...
11A1.
..1..
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x-1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y-1][x] != '.'){
/*
.....
..1..
11A1.
..1..
.....
*/
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-1][x+1] != '.'){
/*
.....
...1.
11A1.
..1..
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x+1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+2][x] != '.'){
}
}else if(s[y][x+2] != '.'){
/*
.....
.....
.1A11
..1..
.....
*/
if(s[y-1][x-1] != '.'){
/*
.....
.1...
.1A11
..1..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x-1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-1][x] != '.'){
/*
.....
..1..
.1A11
..1..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-1][x+1] != '.'){
/*
.....
...1.
.1A11
..1..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x+1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y-1][x+2] != '.'){
/*
.....
....1
.1A11
..1..
.....
*/
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x+2];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+2][x] != '.'){
}
}else if(s[y-1][x-1] != '.'){
/*
.....
.1...
.1A1.
..1..
.....
*/
if(s[y-2][x-1] != '.'){
}else if(s[y-1][x-2] != '.'){
/*
.....
11...
.1A1.
..1..
.....
*/
b++;
paallac = s[y-1][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x-1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y][x-2] != '.'){
/*
.....
.1...
11A1.
..1..
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x-1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y][x+2] != '.'){
/*
.....
.1...
.1A11
..1..
.....
*/
b++;
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x-1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y+2][x] != '.'){
/*
.....
.1...
.1A1.
..1..
..1..
*/
b++;
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x-1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}
}else if(s[y-1][x+1] != '.'){
/*
.....
...1.
.1A1.
..1..
.....
*/
if(s[y-2][x+1] != '.'){
}else if(s[y][x-2] != '.'){
/*
.....
...1.
11A1.
..1..
.....
*/
b++;
paallac = s[y][x-2];
edessac = s[y+1][x];
takanac = s[y-1][x+1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y][x+2] != '.'){
/*
.....
...1.
.1A11
..1..
.....
*/
b++;
paallac = s[y][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x+1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}else if(s[y-1][x+2] != '.'){
/*
.....
...11
.1A1.
..1..
.....
*/
paallac = s[y-1][x+2];
edessac = s[y+1][x];
takanac = s[y-1][x+1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
b++;
}else if(s[y+2][x] != '.'){
/*
.....
...1.
.1A1.
..1..
..1..
*/
b++;
paallac = s[y+2][x];
edessac = s[y+1][x];
takanac = s[y-1][x+1];
alhaallac = s[y][x];
vasemmallac = s[y][x-1];
oikeallac = s[y][x+1];
}
}
}
if(b == 1){
countteri++;
}
paalla = paallac - '0';
edessa = edessac - '0';
takana = takanac - '0';
alhaalla = alhaallac - '0';
vasemmalla = vasemmallac - '0';
oikealla = oikeallac - '0';
vastaukset.push_back({paalla, edessa, vasemmalla, oikealla, takana, alhaalla});
}
/* if(countteri != n){
return 1;
}else{
cout << "vaarin\n";
}*/
for(int i = 0; i < vastaukset.size(); i++){
/*cout << i << ": \n";
cout << "paalla: " << vastaukset[i][0] << "\n";
cout << "edessa: " << vastaukset[i][1] << "\n";
cout << "vasemmalla: " << vastaukset[i][2] << "\n";
cout << "oikealla: " << vastaukset[i][3] << "\n";
cout << "takana: " << vastaukset[i][4] << "\n";
cout << "alhaalla: " << vastaukset[i][5] << "\n";
cout << "\n";
cout << "\n";*/
}
for(int i = 0; i < vastaukset.size(); i++){
bool bo = true;
for(int j = 0; j < vastaukset.size(); j++){
// cout << i << ": " << j << "\n";
if(i == j) continue;
/* for(auto u : vastaukset[i]) {
cout << u << " ";
}
cout << ", ";
for(auto u : vastaukset[j]){
cout << u << " ";
}
cout << "::: ";*/
if(tarkista(vastaukset[i], vastaukset[j]) || samat(vastaukset[i], vastaukset[j])){
//if(i != j && tarkista(ve1, ve2)){
cout << j+1 << " ";
bo = false;
// cout << 1 << "\n";
}else{
// cout << 0 << "\n";
}
}
if(bo){
cout << "-";
}
cout << "\n";
}
}