#include using namespace std; #define ll long long ll parse_number() { size_t lines; cin >> lines; string s, prev; ll res = 1; cin >> s; size_t prev_idx = 0; for(size_t i = 0; i < s.size(); ++i) { if(s[i] == '#'){ prev_idx = i; break; } } for(size_t i = 1; i < lines; ++i) { cin >> s; res <<= 1; if(prev_idx < s.size()-1 && s[prev_idx + 1] == '#') { prev_idx++; } else { res++; prev_idx--; } } return res; } void print_number(ll x) { vector positions; //= {0}; size_t prev_idx = 0; while(x > 0) { if(x % 2 == 0) { positions.push_back(prev_idx--); } else { positions.push_back(prev_idx++); } x >>= 1; } // for(auto& x: positions) cout << x << " "; // cout << "\n"; // reverse and start from 0 ll min = positions.size(); ll max = -min; for(auto& x: positions){ if(x > max) max = x; if(x < min) min = x; } for(auto& x: positions) { x = x - min; } reverse(positions.begin(), positions.end()); max = max - min + 1; cout << positions.size() << "\n"; for(auto& x: positions) { for(ll i = 0; i < max; ++i) { if(x == i) cout << "#"; else cout << "."; } cout << "\n"; } } void testcase() { ll a = parse_number(); ll b = parse_number(); // cout << a << "+" << b << "=" << a+b << "\n"; print_number(a+b); } int main() { testcase(); }