#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, q;
int t[4*MAXN];
int a[MAXN];
void build(int v, int tl, int tr){
    if(tl == tr){
        t[v] = a[tl];
    }else{
        int tm = (tl + tr) / 2;
        build(2*v, tl, tm);
        build(2*v + 1, tm + 1, tr);
        t[v] = (t[2*v] ^ t[2*v + 1]);
    }
}

void upd(int v, int tl, int tr, int pos){
    if(tl == tr){
        t[v] = a[tl];
    }else{
        int tm = (tl + tr) / 2;
        if(pos <= tm)
            upd(2*v, tl, tm, pos);
        else
            upd(2*v + 1, tm + 1, tr, pos);
        t[v] = (t[2*v] ^ t[2*v + 1]);
    }
}


int gt(int v, int tl, int tr, int l, int r){
    if(l > r) return 0;
    if(tl == l && tr == r){
        return t[v];
    }else
    {
        int tm = (tl + tr) / 2;
        return (gt(2*v, tl, tm, l, min(tm, r)) ^ gt(2*v + 1, tm + 1, tr, max(tm + 1, l), r));
    }
}




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    cin>>n>>q;

    for(int i = 0; i < n; i++)
        cin>>a[i];

    build(1, 0, n - 1);

    while(q--){
        int t;
        cin>>t;
        if(t == 1){
            int x, y;
            cin>>x>>y;
            x--;
            a[x] ^= y;
            upd(1, 0, n - 1, x);
        }else{
            int l, r;
            cin>>l>>r;
            cout<<gt(1, 0, n - 1, l - 1, r - 1)<<endl;
        }
    }
    

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}
/********include********/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
//#include <atcoder/all>

/***/
//#include <iomanip>
//#include <cmath>
#include <bits/stdc++.h>


/********define********/
const int MAX = 510000;
const int MOD = 1000000007;


#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;i--)
#define REP(i,n,x) for(long long i=n;i<x;i++)
#define REPN(i,n,x) for(long long i=n+1;i<x;i++)

#define pr printf
#define re return
#define mod 1000000007
//#define mod 998244353
#define inf  INT_MAX//19桁
#define INF 1e18+5//19桁
const double PI=3.14159265358979323846;
#define fi first
#define se second
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define all(x) (x).begin(),(x).end()

typedef long long int ll;
typedef pair<long long, long long> P;


/********変数宣言********/
//vector<long long> g[200020];
vector<pair<long long,long long>> g[200020];
ll s[200020];
bool used[200020];
//bool dp[100005];

ll A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Q,R,S,T,U,V,W,X,Y,Z;
double dA,dB,dC,dD,dE,dF,dG,dH,dI,dJ,dK,dL,dM,dN,dO,dP,dQ,dR,dS,dT,dU,dV,dW,dX,dY,dZ;


string sa,sb,sc,sd,se,sf,sg,sh,si,sj,sk,sl,sm,sn,so,sp,sq,sr,ss, su,sv,sw,sx,sy,sz;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>N;cin>>M;

	vector<string>v(M);
	
	vector<pair<long long, string> > p(M);
	//sort(p.begin(), p.end());
	//sort(p.begin(), p.end(),greater<pair<long long,long long> >());
	
	rep(j,M){
		cin>>v[j];
	}
	rep(i,M){
		p[i].fi=v[i].size();
		p[i].se=v[i];
	}
	sort(p.begin(), p.end());
	ll check;
	check=0;
	ll i;
	i=0;
	ll flg;
	while(check<N*N && i<M){
		
			
		if(check%N!=0){
			if(p[i-1].se[p[i-1].se.size()-1]==p[i].se[0]){
				rep(j,p[i].se.size()-1){
					p[i].se[j]=p[i].se[j+1];
				}
				p[i].se.resize(p[i].se.size()-1);
			}
		}
		
		
		if(check%N+p[i].se.size()<=N){
			cout<<p[i].se;
			check+=p[i].se.size();
			if(check%N==0){
				cout<<"\n";
			}
		}
		else{
			while(check%N!=0){
				cout<<".";
				check++;
			}
			cout<<"\n";
		}
		i++;
	}
	re 0;
}
