#include int main () { int N, M; std::cin >> N; std::string line; std::vector arr1; for (int i = 0; i < N; ++i) { std::cin >> line; for (int j = 0; j < static_cast(line.size()); ++j) { if (line[j] == '#') { arr1.push_back(j); break; } } } arr1.push_back(-1); std::cin >> M; std::vector arr2; for (int i = 0; i < M; ++i) { std::cin >> line; for (int j = 0; j < static_cast(line.size()); ++j) { if (line[j] == '#') { arr2.push_back(j); break; } } } arr2.push_back(-1); int num1 = 1; for (int i = 0; i < N; ++i) { int pos1 = arr1[i]; int pos2 = arr1[i+1]; if (pos2 == -1) break; if (pos2 > pos1) num1 *= 2; else num1 = num1*2+1; } int num2 = 1; for (int i = 0; i < M; ++i) { int pos1 = arr2[i]; int pos2 = arr2[i+1]; if (pos2 == -1) break; if (pos2 > pos1) num2 *= 2; else num2 = num2*2+1; } //std::cout << num1 << ", " << num2 << std::endl; int sum = num1 + num2; int min = INT_MAX; int max = INT_MIN; int pos = 0; min = std::min(min, pos); max = std::max(max, pos); std::vector arr; arr.push_back(0); while (sum > 1) { if (sum % 2 == 0 || sum / 2 == 1) { pos -= 1; arr.push_back(pos); min = std::min(min, pos); } else { pos += 1; max = std::max(max, pos); arr.push_back(pos); } sum /= 2; //std::cout << "sum:" << sum << std::endl; } int len = max - min + 1; //for (int j = 0; j < len; ++j) std::cout << arr[j] << ", "; std::cout << arr.size() << std::endl; //std::cout << "Len: " << len << std::endl; for (int i = static_cast(arr.size()) - 1; i >= 0; --i) { for (int j = 0; j < len; ++j) { if (j != std::abs(arr[i] - min)) std::cout << "."; else std::cout << "#"; } std::cout << std::endl; } return 0; }