#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

#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()
#define setmin(x, y) x = min(x, y)
#define setmax(x, y) x = max(x, y)

int geta(){
    int x; cin >> x;
    int a = 1;
    int pos = 0;
    string s; cin >> s;
    rep(i, 0, s.size()) {
        if(s[i] == '#') pos = i;
    }
    rep(i, 0, x - 1) {
        string s; cin >> s;
        a *= 2;
        int npos = -1;
        rep(i, 0, s.size()) {
            if(s[i] == '#') npos = i;
        }
        if(npos < pos) a++;
        pos = npos;
    }

    return a;
}

signed main(){
    int a = geta();
    int b = geta();
    
    int c = a + b;
    int pos = 50, mnpos = 50, mxpos = 50;
    vector<string> v;
    while(c > 0) {
        v.push_back(string(100, '.'));
        v.back()[pos] = '#';
        setmin(mnpos, pos);
        setmax(mxpos, pos);
        if(c % 2) pos++;
        else pos--;
        c /= 2;
    }

    cout << v.size() << "\n";
    for (int i = v.size() - 1; i >= 0; i--) {
        rep(j, mnpos, mxpos + 1) {
            cout << v[i][j];
        }
        cout << "\n";
    }
    
}