#include using namespace std; #define int long long #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x),end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; typedef vector> vvi; typedef vector> vpii; template using vec = vector; template using uset = unordered_set; template using umap = unordered_map; int parse() { int N; cin >> N; string s; int x = 1; int lastI = -1; getline(cin, s); rep(i, 0, N) { getline(cin, s); int hashI = s.find('#'); if (lastI != -1) { x = (x << 1) + (lastI > hashI); } lastI = hashI; } return x; } void show(int x) { vi ps { 0 }; while (x) { if (x & 1) ps.push_back(ps.back() + 1); else ps.push_back(ps.back() - 1); x >>= 1; } ps.pop_back(); int min = *min_element(all(ps)); for (auto & p : ps) p -= min; cout << sz(ps) << endl; int w = *max_element(all(ps)); for (auto it = ps.rbegin(); it != ps.rend(); ++it) { auto p = *it; rep(i, 0, p) cout << '.'; cout << '#'; rep(i, 0, w - p) cout << '.'; cout << endl; } } void solve() { int a = parse(), b = parse(); show(a + b); } signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); ll T = 1; // cin >> T; rep(i, 0, T) solve(); }