#include #include #include int read_n() { int l, n = 1; std::cin >> l; std::string line; std::cin >> line; unsigned curpos = std::find(line.begin(), line.end(), '#') - line.begin(); for (int i = 1; i < l; i++) { line.clear(); std::cin >> line; n <<= 1; unsigned nextpos = std::find(line.begin(), line.end(), '#') - line.begin(); if (nextpos < curpos) { n |= 1; } curpos = nextpos; } return n; } int main () { int a = read_n(), b = read_n(); int n = a + b; std::vector pos(1, 0); int curpos = 0; while (n != 1) { if (n & 1) curpos++; else curpos--; pos.push_back(curpos); n >>= 1; } int min = *std::min_element(pos.begin(), pos.end()); int max = *std::max_element(pos.begin(), pos.end()); int width = max - min, length = pos.size(); std::cout << length << '\n'; for (int i = length - 1; i >= 0; i--) { int pospos = (pos[i] - min); std::cout << std::string(pospos, '.') << '#' << std::string(width - pospos, '.') << '\n'; } return 0; }