#include #include using namespace std; int main() { int n1, n2, a = 1, b = 1, prev = 0; cin >> n1; for (int i = 0; i < n1; i++) { string str; cin >> str; for (int j = 0; j < str.size(); j++) { if (str[j] == '#') { if (i == 0) { prev = j; break; } if (prev < j) { a = a * 2; } else { a = a * 2 + 1; } prev = j; } } } cin >> n2; for (int i = 0; i < n2; i++) { string str; cin >> str; for (int j = 0; j < str.size(); j++) { if (str[j] == '#') { if (i == 0) { prev = j; break; } if (prev < j) { b = b * 2; } else { b = b * 2 + 1; } prev = j; } } } vector positions = {1}; int answer = a + b; while(answer > 1) { if (answer % 2 == 0) { positions.push_back(positions.back() - 1); } else { positions.push_back(positions.back() + 1); } answer = answer / 2; } int min = positions.front(); int max = positions.front(); for (int i = 1; i < positions.size(); i++) { if (positions[i] < min) { min = positions[i]; } if (positions[i] > max) { max = positions[i]; } } max -= min; for (int & position : positions) { position = position - min; } cout << positions.size() << '\n'; for (int i = positions.size() - 1; i >= 0; i--) { for (int j = 0; j < positions[i]; j++) { cout << '.'; } cout << '#'; for (int j = positions[i] + 1; j <= max; j++) { cout << '.'; } cout << '\n'; } return 0; }