#include using namespace std; using ll=long long; random_device seed_gen; mt19937_64 engine(seed_gen()); ll randint(ll l,ll r){return l+engine()%(r-l);} vector arttobit(string s){ vector e; for(auto i:s)e.emplace_back(i=='#'); return e; } string bittoart(vector a){ string s=""; for(auto i:a)s+=(i?'#':'.'); return s; } int hw; ll m,b; vector bpow; ll bittohash(vector a){ ll t=0; for(int i=0;i>n>>u; int h,w;cin>>h>>w; hw=h*w; bpow.resize(hw+1);bpow[0]=1; for(int i=0;i> g; vector t(n); map> mh; for(int x=0;x>f; int e; if(x>c; s+=c; } t[x]=s; vector p=arttobit(s); ll u=bittohash(p); g.emplace_back(u,e); mh[u]={x,-1}; if(f){ for(int i=0;i=(1< e={u,0}; int l=0,r=g.size(); while(r-l>1){ int m=(l+r)/2; if(g[m].first<=e.first)l=m; else r=m; } if(g[l].first!=e.first){ string s=""; for(int j=0;js)l=i,s=ns; i=r-1; } cout< e(h);pair o=mh[g[l].first]; for(int i=0;i