#include <stdio.h>

int constantine_to_decimal(){
    int rows;
    scanf("%d", &rows);

    int arr[rows];
    char radek[rows];
    for (int i = 0; i < rows; i++){
        scanf("%s", radek);
        for(int n = 0; n < rows; n++){
            if(radek[n] == '#')
                {arr[i] = n;break;}
        }
    }
    
    int val = 1;
    for (int i = 0; i < rows - 1; i++)
    {
        val *=2;

        if(arr[i + 1] == arr[i] - 1){
            val ++;
        }
    }
    return val;
}

int main(){

//int val1, val2;
int dec = constantine_to_decimal();
int dec2 = constantine_to_decimal();

dec += dec2;
// printf("%d\n", dec);

int left = 0, right = 0, current = 0;
int size[30];
int counter = 0;

while(dec != 1){
    if(dec%2 == 0){
        current --;
        size[counter] = current;
        if(current < left)
            left = current;
    }
    else{ //if (dec % 2 == 1)
        current ++;
        size[counter] = current;
        if(current > right)
            right = current;
    }
    dec /= 2;
    counter ++;    
}
counter++;
int width = 1 + right + (-1*left);
//printf("Width = %d (left = %d, right =%d)", width, left, right);
printf("%d\n", counter);
for(int i = 0; i < counter; i++){

    for(int n = 0; n < width; n++)
    {
        size[counter - 2 - i] + (-1*left) == n ? printf("#") : printf(".");
    }
    printf("\n");

}

return 0;
}
