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

int main()
{
    int N,M;
    string a;

    cin >> N >> M;

    for(int i=0; i<M; i++) {
        cin >> a;
    }

    for(int y=0; y<N; y++) {
        for(int x=0; x<N; x++)
        cout << ".";
        cout << endl;
    }
};


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

vector<vector<char>> mat;
vector<pair<int,string>> in;
vector<string> in2;
vector<string> in3;
vector<string> in4;
vector<string> in5;
vector<string> in6;
vector<string> in7;
vector<string> in8;
vector<string> in9;
vector<string> in10;
vector<string> in11;
vector<string> in12;
vector<string> concat_in;
int n,m;

void answer_print(){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){        
            cout << mat[i][j] ;
            if(j==n-1) cout << endl;
        }
    }
}

bool isPut(int x,int y,string str){
    if(mat[y][x] != '.') return false;
    if(n-x+1 < str.size()) return false;
    return true;
}

void Put(int x,int y,string str){
    for(int i = x;i<x+str.size();i++){
        mat[y][i] = str[i-x];
    }
}

void solve(){
    int k=0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(isPut(j,i,concat_in[k])) {
                Put(j,i,concat_in[k]);
                k++;
            }
        }
    }
}

int main(){

    // input
    cin >> n >> m;
    mat.resize(n);in.resize(m);
    for(int i=0;i<n;i++) mat[i].resize(n,'.');

    for(int i=0;i<m;i++) {
        cin >>in[i].second;
        in[i].first = in[i].second.size();
    }

    for(int i=0;i<in.size();i++){
        switch(in[i].first){
            case 2 : in2.push_back(in[i].second);break;
            case 3 : in3.push_back(in[i].second);break;
            case 4 : in4.push_back(in[i].second);break;
            case 5 : in5.push_back(in[i].second);break;
            case 6 : in6.push_back(in[i].second);break;
            case 7 : in7.push_back(in[i].second);break;
            case 8 : in8.push_back(in[i].second);break;
            case 9 : in9.push_back(in[i].second);break;
            case 10 : in10.push_back(in[i].second);break;
            case 11 : in11.push_back(in[i].second);break;
            case 12 : in12.push_back(in[i].second);break;
            default: break;
        }
    }
    for(int i=0;i<in2.size();i++) concat_in.push_back(in2[i]);
    for(int i=0;i<in3.size();i++) concat_in.push_back(in3[i]);
    for(int i=0;i<in4.size();i++) concat_in.push_back(in4[i]);
    for(int i=0;i<in5.size();i++) concat_in.push_back(in5[i]);
    for(int i=0;i<in6.size();i++) concat_in.push_back(in6[i]);
    for(int i=0;i<in7.size();i++) concat_in.push_back(in7[i]);
    for(int i=0;i<in8.size();i++) concat_in.push_back(in8[i]);
    for(int i=0;i<in9.size();i++) concat_in.push_back(in9[i]);
    for(int i=0;i<in10.size();i++) concat_in.push_back(in10[i]);
    for(int i=0;i<in11.size();i++) concat_in.push_back(in11[i]);
    for(int i=0;i<in12.size();i++) concat_in.push_back(in12[i]);

    solve();
    
    answer_print();

}