#include using namespace std; typedef long long ll; typedef pair pi; typedef vector vi; #define sz(x) ((ll)(x).size()) #define all(x) begin(x), end(x) #define rep(i, a, b) for(int i = a; i < (b); ++i) ll to_num() { int n; cin >> n >> ws; string line; ll num = 1; ll prev_idx = -1; ll current_idx = -1; for (int i = 0; i < n; ++i) { getline(cin, line); for (ll h = 0; h < sz(line); ++h) { if (line.at(h) == '#') { current_idx = h; break; } } if (i != 0) { if (current_idx - prev_idx > 0) { num *= 2; } else { num *= 2; num += 1; } } prev_idx = current_idx; } return num; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin.exceptions(ios::failbit); ll lhs = to_num(); ll rhs = to_num(); ll result = lhs + rhs; ll shifted = result; ll bit_idx = 0; for (; bit_idx < 64; ++bit_idx) { unsigned long long mask = 0b1000000000000000000000000000000000000000000000000000000000000000; if (shifted & mask) break; shifted <<= 1; } ll bit_width = 64 - bit_idx; ll orig_shifted = shifted; shifted <<= 1; ll pos = 0; ll min_pos = 0; ll max_pos = 0; for (; bit_idx < 63; ++bit_idx) { unsigned long long mask = 0b1000000000000000000000000000000000000000000000000000000000000000; if (shifted & mask) { --pos; } else { ++pos; } max_pos = max(max_pos, pos); min_pos = min(min_pos, pos); shifted <<= 1; } pos = -min_pos; ll width = max_pos - min_pos + 1; shifted = orig_shifted; cout << bit_width << '\n'; for (ll row = 0; row < bit_width; ++row) { unsigned long long mask = 0b1000000000000000000000000000000000000000000000000000000000000000; for (ll i = 0; i < pos; ++i) cout << '.'; cout << "#"; for (ll i = pos + 1; i < width; ++i) cout << '.'; cout << '\n'; shifted <<= 1; if (shifted & mask) { --pos; } else { ++pos; } } }