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

using ll = long long;

constexpr int inf32 = (1 << 30) - 1;
constexpr ll inf64 = (1LL << 62) - 1LL;
constexpr int mod = 1e9 + 7;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) x.begin(),x.end()

int main(){
	//cout << fixed << setprecision(10);
	int n, m; cin >> n >> m;
	vector<string> vecs(m);
	rep(i, m) cin >> vecs[i];

	rep(i, n) {
		string s;
		while (true) {
			int r = rand() % m;
			s += vecs[r];
			if (s.length() > n) 
				break;
		}
		s = s.substr(0, n);
		cout << s << endl;
	}
	return 0;
}
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
// typedef pair<int,int> P;
// typedef pair<int,P> IP;
// typedef pair<P,P> PP;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N,M;
string S[800];

void solve(vector<vector<char>> &ans){
    rep(i,N){
        rep(j,S[i].size()){
            ans[i][j]=S[i][j];
        }
    }
}

int main(){
    cin>>N>>M;
    rep(i,M) cin>>S[i];

    vector<vector<char>> ans(N,vector<char>(N,'.'));
    
    solve(ans);

    rep(i,N){
        rep(j,N) cout<<ans[i][j];
        cout<<endl;
    }

    return 0;
}