Problem

N strings {S1, S2, ..., SN} are given. Then Q queries are given. There are two types of queries:

1. When a, b, c, d are input, the substring from the bth character of Sa is connected after the substring up to the d-1 character of Sc. Let this be the new Sc. Concatenate the substring from the dth character of the original Sc after the substring up to the b-1 character of Sa. Let this be the new Sa.
2. a, b, c are entered and the b character of Sa is changed to c.



For example, when there are S1 = "abcd" and S2 = "efgh" and the query type is 1 and a = 1, b = 2, c = 2, d = 3.


a ---> bcd
X
ef ---> gh


S1 = "agh", S2 = "efbcd".

Output all SNs from the string S1 after processing all the queries.

Constraints

* 1 ≤ N ≤ 105
* 1 ≤ Q ≤ 105
* The total length of N strings does not exceed 2 x 106.
* The string Si is guaranteed to be all lowercase.
* When the query type is 1
* a ≠ c
* 1 ≤ b ≤ | Sa |
* 1 ≤ d ≤ | Sc |
* When the query type is 2
* 1 ≤ b ≤ | Sa |
* c is guaranteed to be lowercase.



High-speed input / output is recommended.

Input

The input is given in the following format.


N Q
S1
S2
...
SN
query1
query2
...
queryQ


Each query is one of the following:


1 a b c d


or


2 a b c


Output

Output the character string after processing each query line by line from S1 to SN.


S1
S2
...
SN


Examples

Input

2 1
abcd
efgh
1 1 2 2 3


Output

agh
efbcd


Input

2 3
abcd
efgh
1 1 2 2 3
2 1 3 x
2 2 4 x


Output

agx
efbxd


Input

10 10
sjcvpauokb
fmeaowomscy
sepeqqfcosrjmonfsv
zapc
aromazjzqoeiqswvcaf
clifpa
dusudcz
qeqdzdtdzlkhc
gkpsjvdvadmf
xrtyxnkolluagwxp
1 4 4 6 3
1 7 1 8 1
2 2 6 o
1 4 4 3 7
2 1 2 i
1 6 3 3 2
1 6 5 1 9
2 10 9 j
1 2 2 7 3
2 3 2 b


Output

sicvpauoeqqifpa
fqdzdtdzlkhc
sb
zapfcosrjmonfsv
aromazjzqoeiqswvcaf
clepkb
qemeaooomscy
dusudcz
gkpsjvdvadmf
xrtyxnkojluagwxp
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

// ??????????????¨????????????

// ????????°???????????°?????????????????§?????????????§???? 2????????????????????¢?´¢??¨??¨???
// http://www.slideshare.net/iwiwi/2-12188757
// ????????????

struct node_t{
  char val;
  node_t *ch[2];
  ll pri;
  int cnt;
  // string sum;
  node_t(char v,ll p):val(v),pri(p),cnt(1){
    // sum = "";
    // sum += v;
    ch[0]=ch[1]=NULL;
  }
};
int count(node_t *t){
  return t==NULL ? 0 : t->cnt;
}
// string sum(node_t *t){
//   return t==NULL ? "" : t->sum;
// }
node_t* update(node_t *t){
  t->cnt = count(t->ch[0]) + 1 + count(t->ch[1]);
  // t->sum = sum(t->ch[0]) + t->val + sum(t->ch[1]);
  return t;
}
node_t* merge(node_t *l, node_t *r){
  if(!l || !r) return !l?r:l;
  if(l->pri > r->pri){
    l->ch[1] = merge(l->ch[1],r);
    return update(l);
  }else{
    r->ch[0] = merge(l,r->ch[0]);
    return update(r);
  }
}
pair<node_t*,node_t*> split(node_t *t, int k){
  if(!t) return make_pair((node_t*)NULL,(node_t*)NULL);
  if(k <= count(t->ch[0])){
    pair<node_t*,node_t*> s = split(t->ch[0],k);
    t->ch[0] = s.second;
    return make_pair(s.first,update(t));
  }else{
    pair<node_t*,node_t*> s = split(t->ch[1],k-count(t->ch[0])-1);
    t->ch[1] = s.first;
    return make_pair(update(t),s.second);
  }
}
node_t* insert(node_t *t,int k,char val,ll pri){
  pair<node_t*,node_t*> lr = split(t,k);
  node_t* v = new node_t(val,pri);
  node_t* p = merge(lr.first,v);
  return merge(p,lr.second);
}
node_t* erase(node_t *t,int k){
  pair<node_t*,node_t*> mr = split(t,k);
  pair<node_t*,node_t*> lm = split(mr.first,k-1);
  return merge(lm.first,mr.second);
}
void renew(node_t *t,int k,char val){
  node_t *target = t;
  vector<node_t*> l;
  int cnt = count(target);
  int left = 0;
  while(true){
    l.push_back(target);
    int lcnt = count(target->ch[0]);
    if(left+lcnt==k)break;
    if(left+lcnt>k)target = target->ch[0];
    if(left+lcnt<k){
      target = target->ch[1];
      left += lcnt+1;
    }
  }
  target->val = val;
  int sz = l.size();
  REP(i_,sz){
    int i = sz-1-i_;
    update(l[i]);
  }
}
void dfs(node_t *t,char *res){
  if(!t)return;
  int lcnt = count(t->ch[0]);
  res[lcnt] = t->val;
  dfs(t->ch[0],res);
  dfs(t->ch[1],res+lcnt+1);
}
void output(node_t *t){
  int len = count(t);
  char ret[len];
  dfs(t,ret);
  REP(i,len)cout<<ret[i];
  cout<<endl;
}

node_t* str[100010];

ll rd(){
  // xorshift
  static ll x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  ll t;
  t = x ^ (x<<11);
  x=y;y=z;z=w;
  return w=(w^(w>>19)^(t^(t>>8)));
}

int main(){
  int N,Q;
  cin >> N >> Q;
  // string S[N];
  // REP(i,N) cin >> S[i];
  REP(i,N){
    string s;
    cin>>s;
    int len = s.size();
    str[i] = new node_t(s[0],rd());
    REPR(j,len){
      str[i] = insert(str[i],count(str[i]),s[j],rd());
    }
  }
  REP(_,Q){
    int q_type;
    cin>>q_type;
    if(q_type == 1){
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      --a;--b;--c;--d;
      pair<node_t*,node_t*> sa = split(str[a],b);
      pair<node_t*,node_t*> sc = split(str[c],d);
      str[a] = merge(sa.first,sc.second);
      str[c] = merge(sc.first,sa.second);
    }else{
      int a,b;
      char c;
      cin>>a>>b>>c;
      --a;--b;
      renew(str[a],b,c);
      // str[a] = erase(str[a],b+1);
      // str[a] = insert(str[a],b,c,rd());
    }
  }
  REP(i,N){
    // cout << output(str[i]) << endl;
    output(str[i]);
  }
  return 0;
}