#include using namespace std; typedef long long ll; typedef pair pll; typedef long double ld; typedef pair pdd; #define vec vector #define For(i, a, n) for(ll i=(ll)a;i pairoperator+(const pair&a, const pair&b){ return {a.first + b.first, a.second + b.second}; } template ostream&operator<<(ostream&os, const pair&c){ return os<<"("< basic_ostream&operator<<(basic_ostream&os, const C&c){ for(auto itr=begin(c);itr!=end(c);++itr){ os<<(itr==begin(c)?"":" ")<<*itr; } return os; } template void dbg(Args&&...args){ ((cerr<> n; ll a = 1; string frow; cin >> frow; ll cols = frow.size(); ll pos; For(i,0,cols){ if(frow[i] == '#'){ pos = i; break; } } For(i,1,n){ string row; cin >> row; a *= 2; if(pos > 0 && row[pos-1]=='#'){ a++; pos--; }else{ pos++; } } cin >> n; ll b = 1; cin >> frow; cols = frow.size(); For(i,0,cols){ if(frow[i] == '#'){ pos = i; break; } } For(i,1,n){ string row; cin >> row; b *= 2; if(pos > 0 && row[pos-1]=='#'){ b++; pos--; }else{ pos++; } } ll c = a+b; vector rbin; pos = 0; ll minimal = 0; ll maximal = 0; while(c > 1){ bool right = c%2; rbin.push_back(right); if(right){ pos++; }else{ pos--; } minimal = min(minimal,pos); maximal = max(maximal,pos); c/=2; } cout << rbin.size()+1 << "\n"; For(row,0,rbin.size()+1){ For(i,0,maximal-minimal+1){ if(i == pos-minimal){ cout << '#'; }else{ cout << '.'; } } cout << "\n"; if(row < rbin.size() && rbin[rbin.size()-1-row]){ pos--; }else{ pos++; } } } int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int t = 1; while(t--)solve(); return 0; }