#include <bits/stdc++.h>
using namespace std;
#define pf push_front
#define pb push_back
#define FOR(i,begin,end) for (int i=begin;i<=end;i++)
#define rep(i,t) for (int i=0;i<t;i++)
#define pii pair<int,int>
#define pi pair<pii,LL>
#define X first
#define Y second
typedef long long LL;
typedef unsigned long long int ulli;
const LL maxN=1e5+7,MOD=1e9+7,INF=1e9+7,N=5000+7;
string str;
int n,q,l,r,data[4*maxN][30],helper[4*maxN],cnt[30],help;
int left(int x)
{return 2*x+1;}
int right(int x)
{return 2*x+2;}
void build(int node, int st, int en)
{
  if(en-st<2)
  {
    data[node][str[st]-'a'+1]=1;
    return ;
  }
  int mid=(st+en)/2;
  build(left(node),st,mid);
  build(right(node),mid,en);
  FOR(i,1,26)
    data[node][i]=data[left(node)][i]+data[right(node)][i];
}
void shift(int node , int st, int en)
{
  if(!helper[node] || en-st<2)
    return ;
  int mid=(st+en)/2;
  helper[left(node)]=helper[node];
  helper[right(node)]=helper[node];
  FOR(i,1,26)
    data[left(node)][i]=0,data[right(node)][i]=0;
  data[left(node)][helper[node]]=mid-st;
  data[right(node)][helper[node]]=en-mid;
  helper[node]=0;
}
int get(int node, int st, int en, int l, int r, int ind)
{
  if(en<=l || r<=st)
    return 0;
  shift(node,st,en);
  if(st>=l && en<=r)
    return data[node][ind];
  int mid=(st+en)/2;
  return get(left(node),st,mid,l,r,ind)+get(right(node),mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind)
{
  if(en<=l || r<=st)
    return ;
  shift(node,st,en);
  if(st>=l && en<=r)
  {
    FOR(i,1,26)
      data[node][i]=0;
    data[node][ind]=en-st;
    helper[node]=ind;
    return ;
  }
  int mid=(st+en)/2;
  update(left(node),st,mid,l,r,ind);
  update(right(node),mid,en,l,r,ind);
  FOR(i,1,26)
    data[node][i]=data[left(node)][i]+data[right(node)][i];
}
main()
{
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  cin>>n>>q>>str;
  build(0,0,n);
  while(q--)
  {
    cin>>l>>r;
    l--;
    bool odd=false,bad=false;
    FOR(i,1,26)
    {
      cnt[i]=get(0,0,n,l,r,i);
      if(cnt[i]&1)
      {
        if(odd)
          bad=true;
        else
          odd=true,help=i;
      }
    }
    if(!bad)
    {
      FOR(i,1,26)
        cnt[i]/=2;
      FOR(i,1,26)
        update(0,0,n,l,l+cnt[i],i),l+=cnt[i];
      if(odd)
        update(0,0,n,l,l+1,help),l++;
      for(int i=26;i>=1;i--)
        update(0,0,n,l,l+cnt[i],i),l+=cnt[i];
    }
  }
  rep(i,n)
  {
    FOR(j,1,26)
    {
      char help='a';
      if(get(0,0,n,i,i+1,j))
      {
        help+=j;
        help--;
        cout<<help;
        break;
      }
    }
  }
  return cout<<"\n",0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxN=1e5+7,MOD=1e9+7,INF=1e9+7,N=5000+7;
string str;
int n,q,l,r,data[4*maxN][30],helper[4*maxN][30],cnt[30],help;
void shift(int node, int st, int en,int ind)
{
  if(helper[node][ind]==-1 || en-st<2)
    return ;
  int mid=st+en>>1;
  helper[2*node+1][ind]=helper[node][ind];
  helper[2*node+2][ind]=helper[node][ind];
  data[2*node+1][ind]=(mid-st)*helper[node][ind];
  data[2*node+2][ind]=(en-mid)*helper[node][ind];
  helper[node][ind]=-1;
}
int get(int l, int r, int ind, int node=0, int st=0, int en=n)
{
  if(en<=l || r<=st)
    return 0;
  if(st>=l && en<=r)
    return data[node][ind];
  shift(node,st,en,ind);
  int mid=st+en>>1;
  return get(l,r,ind,2*node+1,st,mid)+get(l,r,ind,2*node+2,mid,en);
}
void update(int l, int r, int ind, int val, int node=0, int st=0, int en=n)
{
  if(en<=l || r<=st)
    return ;
  if(st>=l && en<=r)
  {
    data[node][ind]=val*(en-st);
    helper[node][ind]=val;
    return ;
  }
  shift(node,st,en,ind);
  int mid=st+en>>1;
  update(l,r,ind,val,2*node+1,st,mid);
  update(l,r,ind,val,2*node+2,mid,en);
  data[node][ind]=data[2*node+1][ind]+data[2*node+2][ind];
}
main()
{
  ifstream cin("input.txt");
  ofstream cout("output.txt");
  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
  cin>>n>>q>>str;
  for(int i=0;i<maxN;i++)
  {
    for(int j=1;j<=26;j++)
      helper[i][j]=-1;
  }
  for(int i=0;i<n;i++)
    update(i,i+1,str[i]-'a'+1,1);
  while(q--)
  {
    cin>>l>>r;
    l--;
    bool odd=false,bad=false;
    for(int i=1;i<=26;i++)
    {
      cnt[i]=get(l,r,i);
      if(cnt[i]&1)
      {
        if(odd)
          bad=true;
        else
          odd=true,help=i;
      }
    }
    if(!bad)
    {
      for(int i=1;i<=26;i++)
        update(l,r,i,0);
      for(int i=1;i<=26;i++)
      {
        int wh=cnt[i]/2;
        update(l,l+wh,i,1);
        update(r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=1;j<=26;j++)
    {
      char help='a';
      if(get(i,i+1,j))
      {
        help+=j;
        help--;
        cout<<help;
        break;
      }
    }
  }
  return cout<<"\n",0;
}


#include <bits/stdc++.h>
using namespace std;
#define pf push_front
#define pb push_back
#define FOR(i,begin,end) for (int i=begin;i<=end;i++)
#define rep(i,t) for (int i=0;i<t;i++)
#define pii pair<int,int>
#define pi pair<pii,LL>
#define X first
#define Y second
#define cin fin
#define cout fout
typedef long long LL;
typedef unsigned long long int ulli;
const LL maxN=1e5+7,MOD=1e9+7,INF=1e9+7,N=5000+7;
string str;
int n,q,l,r,data[4*maxN][30],helper[4*maxN],cnt[30],help;
int left(int x)
{return 2*x+1;}
int right(int x)
{return 2*x+2;}
void build(int node, int st, int en)
{
  if(en-st<2)
  {
    data[node][str[st]-'a'+1]=1;
    return ;
  }
  int mid=(st+en)/2;
  build(left(node),st,mid);
  build(right(node),mid,en);
  FOR(i,1,26)
    data[node][i]=data[left(node)][i]+data[right(node)][i];
}
void shift(int node , int st, int en)
{
  if(!helper[node] || en-st<2)
    return ;
  int mid=(st+en)/2;
  helper[left(node)]=helper[node];
  helper[right(node)]=helper[node];
  FOR(i,1,26)
    data[left(node)][i]=0,data[right(node)][i]=0;
  data[left(node)][helper[node]]=mid-st;
  data[right(node)][helper[node]]=en-mid;
  helper[node]=0;
}
int get(int node, int st, int en, int l, int r, int ind)
{
  if(en<=l || r<=st)
    return 0;
  shift(node,st,en);
  if(st>=l && en<=r)
    return data[node][ind];
  int mid=(st+en)/2;
  return get(left(node),st,mid,l,r,ind)+get(right(node),mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind)
{
  if(en<=l || r<=st)
    return ;
  shift(node,st,en);
  if(st>=l && en<=r)
  {
    FOR(i,1,26)
      data[node][i]=0;
    data[node][ind]=en-st;
    helper[node]=ind;
    return ;
  }
  int mid=(st+en)/2;
  update(left(node),st,mid,l,r,ind);
  update(right(node),mid,en,l,r,ind);
  FOR(i,1,26)
    data[node][i]=data[left(node)][i]+data[right(node)][i];
}
main()
{
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  cin>>n>>q>>str;
  build(0,0,n);
  while(q--)
  {
    cin>>l>>r;
    l--;
    bool odd=false,bad=false;
    FOR(i,1,26)
    {
      cnt[i]=get(0,0,n,l,r,i);
      if(cnt[i]&1)
      {
        if(odd)
          bad=true;
        else
          odd=true,help=i;
      }
    }
    if(!bad)
    {
      FOR(i,1,26)
        cnt[i]/=2;
      FOR(i,1,26)
        update(0,0,n,l,l+cnt[i],i),l+=cnt[i];
      if(odd)
        update(0,0,n,l,l+1,help),l++;
      for(int i=26;i>=1;i--)
        update(0,0,n,l,l+cnt[i],i),l+=cnt[i];
    }
  }
  rep(i,n)
  {
    FOR(j,1,26)
    {
      char help='a';
      if(get(0,0,n,i,i+1,j))
      {
        help+=j;
        help--;
        cout<<help;
        break;
      }
    }
  }
  return cout<<"\n",0;
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,(k[i]+1)/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,(k[i]+1)/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,bool ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i])
				cout << char('a'+i);
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
	}

	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour1(int id)
{
	for2(i,0,30)
	{
		seg[id][i] = (k[i]%2);
		k[i] -= (k[i]%2);
	}
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,k[i]/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,int ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr = 5)
		{
			pour1(id);
			return;
		}
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		if(!c){
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
		}
		else
		{
			add(0,SZ-1,1,mid,mid,5);
			add(0,SZ-1,1,l,mid-1,1);
			add(0,SZ-1,1,mid+1,r,0);
		}
	}
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[5*maxn][30];
int lazy[5*maxn];
int k[30];
int kp[30];

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour1(int id)
{
	for2(i,0,30)
	{
		seg[id][i] = (k[i]%2);
		k[i] -= (k[i]%2);
	}
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,k[i] - kp[i]/2  );
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,int ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr == 5)
		{
			pour1(id);
			return;
		}
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;

		for2(i,0,30) kp[i] = k[i];
		if(!c){
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
		}
		else
		{
			add(0,SZ-1,1,mid,mid,5);
			add(0,SZ-1,1,l,mid-1,1);
			add(0,SZ-1,1,mid+1,r,0);
		}
	}
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void add(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p = seg[id][i] - min(c,seg[id][i]);
		c -= min(c,seg[id][i]);
		if(!c)
		{
			if(lazy[id] == 1) t ++;
			else              t --;
			seg[t][i] += p;
			c = r - (l+r)/2;
			c -= p;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,r);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
}

void inline pour(int id,int c)
{
	fill(seg[id],seg[id]+30,0);
	for2(i,0,30)
	{
		int p = min(c,(k[i]+1)/2);
		seg[id][i] += p;
		c -= p;
		k[i] -= p;
	}
}

void add(int L,int R,int id,int l,int r,bool ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,r-l+1);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,l,r);
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );
}

void relax(int l,int r,int id)
{
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i])
				cout << char('a'+i);
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		add(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
	}/*
	for2(i,1,SZ*2){
		error(i);
		cout << seg[i][0] << ' ' << seg[i][1] << ' ' << seg[i][2] << endl;
	}*/
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[5*maxn][30];
int lazy[5*maxn];
int k[30];
int kp[30];
int qwe;

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour1(int id)
{
	seg[id][qwe] = 1;
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,kp[i]  );
			seg[id][i] += p;
			c -= p;
			kp[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,int ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr == 5)
		{
			pour1(id);
			return;
		}
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;

		for2(i,0,30){
			if(k[i]%2) qwe = i;
			kp[i] = k[i]/2 ;
			k[i] = k[i]/2;
		}
		if(!c){
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
		}
		else
		{
			add(0,SZ-1,1,mid,mid,5);
			add(0,SZ-1,1,l,mid-1,1);
			add(0,SZ-1,1,mid+1,r,0);
		}
	}
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[5*maxn][30];
int lazy[5*maxn];
int k[30];
int kp[30];
int qwe;

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour1(int id)
{
	fill(seg[id],seg[id]+30,0);
	seg[id][qwe] = 1;
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,kp[i]);
			seg[id][i] += p;
			c -= p;
			kp[i] -= p;
		}
	else
	{
	//	for(int i = 29; i >= 0; i --)
		for2(i,0,30)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,int ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr == 5)
		{
			pour1(id);
			return;
		}
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;

		for2(i,0,30){
			if(k[i]%2) qwe = i;
			kp[i] = k[i]/2 ;
			k[i] = k[i]/2;
		}
		if(!c){
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
		}
		else
		{
			add(0,SZ-1,1,mid,mid,5);
			add(0,SZ-1,1,l,mid-1,1);
			add(0,SZ-1,1,mid+1,r,0);
		}
	}
	/*
	error(seg[2][0]);
	error(seg[2][1]);
	error(seg[12][0]);
	error(seg[12][1]);*/
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour1(int id)
{
	for2(i,0,30)
	{
		seg[id][i] = 0;
		seg[id][i] += (k[i]%2);
	}
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,k[i]/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,int ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr = 5)
		{
			pour1(id);
			return;
		}
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		if(!c){
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
		}
		else
		{
			add(0,SZ-1,1,l,mid-1,1);
			add(0,SZ-1,1,mid,mid,5);
			add(0,SZ-1,1,mid+1,r,0);
		}
	}
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,(k[i]+1)/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,(k[i]+1)/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,bool ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
				return;
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
	}

	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void add(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p = seg[id][i] - min(c,seg[id][i]);
		c -= min(c,seg[id][i]);
		if(!c)
		{
			if(lazy[id] == 1) t ++;
			else              t --;
			seg[t][i] += p;
			c = r - (l+r)/2;
			c -= p;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,r);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
}

void inline pour(int id,int c)
{
	fill(seg[id],seg[id]+30,0);
	for2(i,0,30)
	{
		int p = min(c,(k[i]+1)/2);
		seg[id][i] += p;
		c -= p;
		k[i] -= p;
	}
}

void add(int L,int R,int id,int l,int r,bool ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,r-l+1);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,l,r);
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );
}

void relax(int l,int r,int id)
{
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i])
				cout << char('a'+i);
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		add(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
	}/*
	for2(i,1,SZ*2){
		error(i);
		cout << seg[i][0] << ' ' << seg[i][1] << ' ' << seg[i][2] << endl;
	}*/
	relax(0,SZ-1,1);
}


#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
using namespace std;
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
int n,m,arr[100005];
struct node{
	int l,r,sum;
};
struct segT{
	node Ns[200005];
	void init(int pos,int l,int r){
		Ns[pos].l=l;
		Ns[pos].r=r;
		Ns[pos].sum=0;
		if(l==r) return;
		int m=(l+r)/2;
		init(pos*2,l,m);
		init(pos*2+1,m+1,r);
	}
	int getsum(int pos,int l,int r){
		if(l<=Ns[pos].l && r>=Ns[pos].r) return Ns[pos].sum;
		if(Ns[pos].sum==Ns[pos].r-Ns[pos].l+1) {
			return (MIN(r,Ns[pos].r)-MAX(l,Ns[pos].l)+1);
		}
		if(Ns[pos].sum==0) return 0;
		int m=(Ns[pos].l+Ns[pos].r)/2,res=0;
		if(l<=m) res+=getsum(pos*2,l,r);
		if(r>m) res+=getsum(pos*2+1,l,r);
		return res;
	}
	int set(int pos,int l,int r,int v,int os){
		if(l<=Ns[pos].l && r>=Ns[pos].r){
			if(os==-1) os=Ns[pos].sum;
			else os*=(Ns[pos].r-Ns[pos].l+1);
			Ns[pos].sum=v*(Ns[pos].r-Ns[pos].l+1);
			return (Ns[pos].sum-os);
		}
		if(Ns[pos].sum==Ns[pos].r-Ns[pos].l+1) os=1;
		if(Ns[pos].sum==0) os=0;
		if(os==0) Ns[pos].sum=Ns[pos*2].sum=Ns[pos*2+1].sum=0;
		if(os==1) {
			Ns[pos].sum=Ns[pos].r-Ns[pos].l+1;
			Ns[pos*2].sum=Ns[pos*2].r-Ns[pos*2].l+1;
			Ns[pos*2+1].sum=Ns[pos*2+1].r-Ns[pos*2+1].l+1;
		}
		int m=(Ns[pos].l+Ns[pos].r)/2,nos=Ns[pos].sum;
		if(l<=m) Ns[pos].sum+=set(pos*2,l,r,v,os);
		if(r>m) Ns[pos].sum+=set(pos*2+1,l,r,v,os);
		return (Ns[pos].sum-nos);
	}
}trees[30];
int nums[30];
void report(){
	int xb,x2;
	for(xb=0;xb<n;xb++){
		for(x2=0;x2<24;x2++){
			if(trees[x2].getsum(1,xb,xb)){
				printf("%c",(char)('a'+x2));
				break;
			}
		}
	}
	printf("\n");
}
int main(){

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	scanf("%d %d",&n,&m);
	int xb,x2,x,y;
	char c;
	for(xb=0;xb<24;xb++) trees[xb].init(1,0,n-1);
	for(xb=0;xb<n;xb++){
		c=getchar();
		while(c==' '||c=='\n') c=getchar();
		arr[xb]=c-'a';
		trees[arr[xb]].set(1,xb,xb,1,-1);
	}
	for(xb=0;xb<m;xb++){
		scanf("%d %d",&x,&y);
		x--;
		y--;
		int oddcnt=0,ods=-1;
		for(x2=0;x2<24 && oddcnt<2;x2++) {
			nums[x2]=trees[x2].getsum(1,x,y);
			if(nums[x2]&1) {
				oddcnt++;
				ods=x2;
			}
		}
		if(oddcnt>1) continue;
		for(x2=0;x2<24;x2++) trees[x2].set(1,x,y,0,-1);
		int used=0;
		for(x2=0;x2<24;x2++){
			if(x2!=ods && nums[x2]>0){
				trees[x2].set(1,x+used,x+used+(nums[x2]/2)-1,1,-1);
				trees[x2].set(1,y-used-(nums[x2]/2)+1,y-used,1,-1);
				used+=nums[x2]/2;
			}
		}
		if(oddcnt){
			trees[ods].set(1,(x+y)/2,(x+y)/2,1,-1);
		}
	}
	report();
	return 0;
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour1(int id)
{
	for2(i,0,30)
	{
		seg[id][i] = 0;
		seg[id][i] += (k[i]%2);
		k[i] -= (k[i]%2);
	}
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,k[i]/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,int ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr = 5)
		{
			pour1(id);
			return;
		}
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		if(!c){
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
		}
		else
		{
			add(0,SZ-1,1,l,mid-1,1);
			add(0,SZ-1,1,mid,mid,5);
			add(0,SZ-1,1,mid+1,r,0);
		}
	}
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[5*maxn][30];
int lazy[5*maxn];
int k[30];
int kp[30];
int qwe;

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour1(int id)
{
	fill(seg[id],seg[id]+30,0);
	seg[id][qwe] = 1;
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,kp[i]);
			seg[id][i] += p;
			c -= p;
			kp[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,int ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr == 5)
		{
			pour1(id);
			return;
		}
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;

		for2(i,0,30){
			if(k[i]%2) qwe = i;
			kp[i] = k[i]/2 ;
			k[i] = k[i]/2;
		}
		if(!c){
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
		}
		else
		{
			add(0,SZ-1,1,mid,mid,5);
			add(0,SZ-1,1,l,mid-1,1);
			add(0,SZ-1,1,mid+1,r,0);
		}
	}
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,(k[i]+1)/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,bool ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
	}
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int SZ = 1,n,m;
int k[30];

struct segment{
	int c[26];
	bool lazy ;
	int sor;
};
segment seg[maxn*3];

bool qwer = 0;

void laz(int L,int R,int id)
{
    int mid = (L+R)/2;
		seg[id*2].lazy = 1;
		seg[id*2+1].lazy = 1;
		seg[id].lazy = 0;
		seg[id*2].sor = seg[id].sor;
		seg[id*2+1].sor = seg[id].sor;
		if(seg[id].sor == -1)
		{
			int SZ = R - mid ;
			int i;
			fill(seg[id*2].c,seg[id*2].c+26,0);
			fill(seg[id*2+1].c,seg[id*2+1].c+26,0);
			for( i = 25; i >=  0; i--)
			{
				if(seg[id].c[i] <= SZ)
				{
					SZ -= seg[id].c[i];
					seg[id*2+1].c[i] = seg[id].c[i];
				}
				else
				{
					seg[id*2+1].c[i] = SZ;
					break;
				}
			}
			seg[id*2].c[i] = seg[id].c[i] - SZ;
			for(int j = i-1; j >= 0; j--)
				seg[id*2].c[j] = seg[id].c[j];
		}
		else
		{
			int SZ = mid - L + 1;
			int i;
			fill(seg[id*2].c,seg[id*2].c+26,0);
			fill(seg[id*2+1].c,seg[id*2+1].c+26,0);
			for( i = 0; i < 26; i++)
			{
				if(seg[id].c[i] <= SZ)
				{
					SZ -= seg[id].c[i];
					seg[id*2].c[i] = seg[id].c[i];
				}
				else
				{
					seg[id*2].c[i] = SZ;
					break;
				}
			}
			seg[id*2+1].c[i] = seg[id].c[i] - SZ;
			for(int j = i+1; j < 26; j++)
			{
				seg[id*2+1].c[j] = seg[id].c[j];
			}
		}
}

void inline add()
{
	for2(i,0,n)
	{
		int id = i + SZ;
		char ch;
		cin >> ch;
		int t = ch - 'a';
		while(id)
		{
			seg[id].c[t] ++;
			id /= 2;
		}
	}
}

void inline pour(int id,bool rtl,int siz)
{
    fill(seg[id].c,seg[id].c+26,0);
    if(qwer == 1)
    {
        qwer = 0;
        for2(i,0,26)
        {
            if(k[i]%2)
            {
                seg[id].c[i] = 1;
                k[i] --;
                return;
            }
        }
    }
	if(!rtl)
	{
		for2(i,0,26)
		{
            if(!siz) break;
			if(k[i]/2 <= siz)
			{
				seg[id].c[i] = k[i]/2  ;
				siz -= k[i]/2 ;
				k[i] -= k[i]/2 ;
			}
			else
			{
				seg[id].c[i] += siz;
				k[i] -= siz;
				siz = 0;
			}
		}
	}
	else
	{
		for(int i =25; i >= 0; i --)
		{
            if(!siz) break;
			if(k[i] <= siz)
			{
				seg[id].c[i] = k[i];
				siz -= k[i];
				k[i] -= k[i]/2;
			}
			else
			{
				seg[id].c[i] += siz;
				k[i] -= siz;
				siz = 0;
			}
		}
	}
}
void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L)
		return ;
	if(l <= L and R <= r)
	{
		for2(i,0,26) k[i] += seg[id].c[i];
		return;
	}
	int mid = (L+R)/2;
	if(seg[id].lazy)
        laz(L,R,id);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
    for2(i,0,26) seg[id].c[i] = seg[id*2].c[i] + seg[id*2+1].c[i];
}

void change(int L,int R,int id,int l,int r,bool rtl)
{
	if(R < l or r < L) return;
	if(l <= L and R <= r)
	{
		if(rtl) seg[id].sor = -1;
		else    seg[id].sor =  1;
		seg[id].lazy = 1;
		pour(id,rtl,R-L+1);
		return;
	}
	int mid = (L+R)/2;

	if(seg[id].lazy)
        laz(L,R,id);
	if(rtl)
		change(mid+1,R,id*2+1,l,r,rtl);
	change(L,mid,id*2,l,r,rtl);
	if(!rtl)
		change(mid+1,R,id*2+1,l,r,rtl);
    for2(i,0,26) seg[id].c[i] = seg[id*2].c[i] + seg[id*2+1].c[i];
}

void prin(int l,int r,int id)
{
    if(l == r) {
        for2(i,0,26)
        if(seg[id].c[i])
        {
            cout << char(i+'a');
        }
        return;
    }

	if(seg[id].lazy)
        laz(l,r,id);
    int mid = (l+r)/2;
    prin(l,mid,id*2);
    prin(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	add();
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if(l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		int qyr = 0;
		fnd(0,SZ-1,1,l,r);
		int t = 0;
		for2(j,0,26){ t += k[j] % 2;}
		if(t > 1) continue ;
		int mid = (l+r)/2;
		if(t == 1){
            qwer = 1;
            change(0,SZ-1,1,mid,mid,0);
            qwer = 0;
            change(0,SZ-1,1,l,mid-1,0);
            change(0,SZ-1,1,mid+1,r,1);
        }
        else
        {
            change(0,SZ-1,1,l,mid,0);
            change(0,SZ-1,1,mid+1,r,1);
        }

	}
    prin(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int SZ = 1,n,m;
int k[30];

struct segment{
	int c[26];
	bool lazy ;
	int sor;

	/// sor lazy = 1 : abc
	/// sor = -1 : cba
	/// sor = 0 : acb

	/// lazy :)
};
segment seg[maxn*3];

void laz(int L,int R,int id)
{
    int mid = (L+R)/2;
		seg[id*2].lazy = 1;
		seg[id*2+1].lazy = 1;
		seg[id].lazy = 0;
		seg[id*2].sor = seg[id].sor;
		seg[id*2+1].sor = seg[id].sor;
		if(seg[id].sor == -1)
		{
			int SZ = R - mid ;
			int i;
			fill(seg[id*2].c,seg[id*2].c+26,0);
			fill(seg[id*2+1].c,seg[id*2+1].c+26,0);
			for( i = 25; i >=  0; i--)
			{
				if(seg[id].c[i] <= SZ)
				{
					SZ -= seg[id].c[i];
					seg[id*2+1].c[i] = seg[id].c[i];
				}
				else
				{
					seg[id*2+1].c[i] = SZ;
					break;
				}
			}
			seg[id*2].c[i] = seg[id].c[i] - SZ;
			for(int j = i-1; j >= 0; j--)
			{
				seg[id*2].c[j] = seg[id].c[j];
			}

		}
		else
		{
			int SZ = mid - L + 1;
			int i;
			fill(seg[id*2].c,seg[id*2].c+26,0);
			fill(seg[id*2+1].c,seg[id*2+1].c+26,0);
			for( i = 0; i < 26; i++)
			{
				if(seg[id].c[i] <= SZ)
				{
					SZ -= seg[id].c[i];
					seg[id*2].c[i] = seg[id].c[i];
				}
				else
				{
					seg[id*2].c[i] = SZ;
					break;
				}
			}
			seg[id*2+1].c[i] = seg[id].c[i] - SZ;
			for(int j = i+1; j < 26; j++)
			{
				seg[id*2+1].c[j] = seg[id].c[j];
			}
		}
}

void inline add()
{
	for2(i,0,n)
	{
		int id = i + SZ;
		char ch;
		cin >> ch;
		int t = ch - 'a';
		while(id)
		{
			seg[id].c[t] ++;
			id /= 2;
		}
	}
}

void inline pour(int id,bool rtl,int siz)
{
//    error(siz);

    fill(seg[id].c,seg[id].c+26,0);
	if(!rtl)
	{
		for2(i,0,26)
		{
            if(!siz) break;
			if(k[i]/2 + k[i]%2 <= siz)
			{
				seg[id].c[i] = k[i]/2 + k[i]%2 ;
				siz -= k[i]/2 + k[i]%2;
				k[i] -= k[i]/2 + k[i]%2;
			}
			else
			{
				seg[id].c[i] += siz;
				k[i] -= siz;
				siz = 0;
			}
		}
	}
	else
	{
		for(int i =25; i >= 0; i --)
		{
            if(!siz) break;
			if(k[i] <= siz)
			{
				seg[id].c[i] = k[i];
				siz -= k[i];
				k[i] -= k[i]/2;
			}
			else
			{
				seg[id].c[i] += siz;
				k[i] -= siz;
				siz = 0;
			}
		}
	}

//        int test = 0;
//        if(L == R and L == 2)
//        {
//            for2(i,0,26) test += k[i];
//        }
//        error(test);

}
void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L)
		return ;
	if(l <= L and R <= r)
	{
		for2(i,0,26) k[i] += seg[id].c[i];
		return;
	}
	int mid = (L+R)/2;
	if(seg[id].lazy)
        laz(L,R,id);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
    for2(i,0,26) seg[id].c[i] = seg[id*2].c[i] + seg[id*2+1].c[i];
}

void change(int L,int R,int id,int l,int r,bool rtl)
{
	if(R < l or r < L) return;
	if(l <= L and R <= r)
	{
		if(rtl) seg[id].sor = -1;
		else    seg[id].sor =  1;
		seg[id].lazy = 1;

//        int test = 0;
//        if(L == R and L == 2)
//        {
//            for2(i,0,26) test += k[i];
//        }
//        error(test);

		pour(id,rtl,R-L+1);

//		int deb = 0;
//		for2(i,0,26)
//		{ deb += seg[id].c[i];};
//		error(deb);
//		error(L);
//		error(R);

		return;
	}
	int mid = (L+R)/2;

	if(seg[id].lazy){
//        error(":/");
        laz(L,R,id);
    }
	if(rtl)
		change(mid+1,R,id*2+1,l,r,rtl);
	change(L,mid,id*2,l,r,rtl);
	if(!rtl)
		change(mid+1,R,id*2+1,l,r,rtl);
    for2(i,0,26) seg[id].c[i] = seg[id*2].c[i] + seg[id*2+1].c[i];
}

void prin(int l,int r,int id)
{
    if(l == r) {
        for2(i,0,26)
        if(seg[id].c[i])
        {
            cout << char(i+'a');
        }
        return;
    }

	if(seg[id].lazy)
        laz(l,r,id);
    int mid = (l+r)/2;
    prin(l,mid,id*2);
    prin(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	add();
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		l --, r--;
		fill(k,k+30,0);
		int qyr = 0;
		fnd(0,SZ-1,1,l,r);

//        int test = 0;
//        if(L == R and L == 2)
//        {
//            for2(i,0,26) test += k[i];
//        }
//        error(test);

//		for2(j,0,26) qyr += seg[1].c[j];
//		error(qyr);

		int t = 0;
		for2(j,0,26){ t += k[j] % 2;}
		if(t > 1) continue ;
		int mid = (l+r)/2;
		change(0,SZ-1,1,l,mid,0);
		change(0,SZ-1,1,mid+1,r,1);
/**
		qyr = 0;
		for2(j,0,26) qyr += seg[1].c[j];
		error(qyr);
		qyr = 0;
		for2(j,0,26) qyr += k[j];
		error(qyr);*/

	}
    prin(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int n,m,SZ = 1;
int seg[3*maxn][30];
int lazy[3*maxn];
int k[30];

inline void preadd(int i,int x) { int id = SZ + i; while(id) { seg[id][x] ++; id /= 2; }  }

void laz(int id,int l,int r)
{
	fill(seg[id*2],seg[id*2]+30,0);
	fill(seg[id*2+1],seg[id*2+1]+30,0);
	int t = id*2;
	if(lazy[id] == -1) t ++;
	int c = (l+r)/2 - l + 1;
	if(lazy[id] == -1)
		c = (r - (l+r)/2);
	bool changed = 0;
	for2(i,0,30)
	{
		seg[t][i] += min(c,seg[id][i]);
		int p =  min(c,seg[id][i]);
		seg[id][i] -= p;
		c -= p;

		if(!c)
		{
			if(changed) break;
			changed = 1;
			if(lazy[id] == 1) t ++;
			else              t --;
			c = r - (l+r)/2;
			if(lazy[id] == -1) c= (r+l)/2 - l + 1;
			i --;
		}
	}
	lazy[id*2] = lazy[id];
	lazy[id*2+1] = lazy[id];
	lazy[id] = 0;
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L) return ;
	if(l <= L and R <= r)
	{
		for2(i,0,30) k[i] += seg[id][i] ;
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]) laz(id,L,R);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i]);
}

void inline pour1(int id)
{
	for2(i,0,30)
	{
		seg[id][i] = (k[i]%2);
		k[i] -= (k[i]%2);
	}
}

void inline pour(int id,int c,bool ltr)
{
	fill(seg[id],seg[id]+30,0);
	if(ltr)
		for2(i,0,30)
		{
			int p = min(c,k[i]/2);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	else
	{
		for(int i = 29; i >= 0; i --)
		{
			int p = min(c,k[i]);
			seg[id][i] += p;
			c -= p;
			k[i] -= p;
		}
	}
}

void add(int L,int R,int id,int l,int r,int ltr)
{
	if(r < L or R < l) return;
	if(l <= L and R <= r)
	{
		if(ltr == 5)
		{
			pour1(id);
			return;
		}
		if(ltr) lazy[id] =  1;
		else    lazy[id] = -1;
		pour(id,R-L+1,ltr);
		return ;
	}
	int mid = (L+R)/2;
	if(lazy[id]){
		laz(id,L,R);
	}
	if(ltr){
		add(L,mid,id*2,l,r,ltr);
		add(mid+1,R,id*2+1,l,r,ltr);
	}
	else
	{
		add(mid+1,R,id*2+1,l,r,ltr);
		add(L,mid,id*2,l,r,ltr);
	}

	//if(seg[id][17] == 9) error(134);

	for2(i,0,30) seg[id][i] = (seg[id*2][i] + seg[id*2+1][i] );

}

void relax(int l,int r,int id)
{
//	error(seg[id]['s'-'a']);
	if(l == r)
	{
		for2(i,0,30)
		{
			if(seg[id][i]){
				cout << char('a'+i);
			}
		}
		return ;
	}
	int mid = (l+r)/2;
	if(lazy[id]) laz(id,l,r);
	relax(l,mid,id*2);
	relax(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);;
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	for2(i,0,n)
	{
		char ch;
		cin >> ch;
		preadd(i,ch-'a');
	}
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		if( l == r) continue;
		l --, r--;
		fill(k,k+30,0);
		fnd(0,SZ-1,1,l,r);
		int c = 0;
		for2(i,0,30) c += (k[i]%2);
		if(c >= 2) continue;
		int mid = (l+r)/2;
		if(!c){
		add(0,SZ-1,1,l,mid,1);
		add(0,SZ-1,1,mid+1,r,0);
		}
		else
		{
			add(0,SZ-1,1,mid,mid,5);
			add(0,SZ-1,1,l,mid-1,1);
			add(0,SZ-1,1,mid+1,r,0);
		}
	}
	relax(0,SZ-1,1);
}


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

#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define Endl "\n"
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max3(a,b,c) max(max(a,b),c)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define Set set<int>
#define error(x) cout << #x << " = " << (x) << endl;
#define get(a,b) for(int i = 0; i < (b); i ++) cin >> (a)[i];

///===========================================================

const ll inf = ~0ull/4;
const ll maxn = 210000;

///===========================================================

int SZ = 1,n,m;
int k[30];

struct segment{
	int c[26];
	bool lazy ;
	int sor;

	/// sor lazy = 1 : abc
	/// sor = -1 : cba
	/// sor = 0 : acb

	/// lazy :)
};
segment seg[maxn*3];

bool qwer = 0;

void laz(int L,int R,int id)
{
//    error(54);
    int mid = (L+R)/2;
		seg[id*2].lazy = 1;
		seg[id*2+1].lazy = 1;
		seg[id].lazy = 0;
		seg[id*2].sor = seg[id].sor;
		seg[id*2+1].sor = seg[id].sor;
		if(seg[id].sor == -1)
		{
			int SZ = R - mid ;
			int i;
			fill(seg[id*2].c,seg[id*2].c+26,0);
			fill(seg[id*2+1].c,seg[id*2+1].c+26,0);
			for( i = 25; i >=  0; i--)
			{
				if(seg[id].c[i] <= SZ)
				{
					SZ -= seg[id].c[i];
					seg[id*2+1].c[i] = seg[id].c[i];
				}
				else
				{
					seg[id*2+1].c[i] = SZ;
					break;
				}
			}
			seg[id*2].c[i] = seg[id].c[i] - SZ;
			for(int j = i-1; j >= 0; j--)
			{
				seg[id*2].c[j] = seg[id].c[j];
			}

		}
		else
		{
			int SZ = mid - L + 1;
			int i;
			fill(seg[id*2].c,seg[id*2].c+26,0);
			fill(seg[id*2+1].c,seg[id*2+1].c+26,0);
			for( i = 0; i < 26; i++)
			{
				if(seg[id].c[i] <= SZ)
				{
					SZ -= seg[id].c[i];
					seg[id*2].c[i] = seg[id].c[i];
				}
				else
				{
					seg[id*2].c[i] = SZ;
					break;
				}
			}
			seg[id*2+1].c[i] = seg[id].c[i] - SZ;
			for(int j = i+1; j < 26; j++)
			{
				seg[id*2+1].c[j] = seg[id].c[j];
			}
		}
}

void inline add()
{
	for2(i,0,n)
	{
		int id = i + SZ;
		char ch;
		cin >> ch;
		int t = ch - 'a';
		while(id)
		{
			seg[id].c[t] ++;
			id /= 2;
		}
	}
}

void inline pour(int id,bool rtl,int siz)
{
//    error(siz);
    fill(seg[id].c,seg[id].c+26,0);
    if(qwer == 1)
    {
        qwer = 0;
//        error(137);
        for2(i,0,26)
        {
            if(k[i]%2)
            {
//                error(char('a'+i));
                seg[id].c[i] = 1;
                k[i] --;
                return;
            }
        }
    }
	if(!rtl)
	{
		for2(i,0,26)
		{
            if(!siz) break;
			if(k[i]/2 <= siz)
			{
				seg[id].c[i] = k[i]/2  ;
				siz -= k[i]/2 ;
				k[i] -= k[i]/2 ;
			}
			else
			{
				seg[id].c[i] += siz;
				k[i] -= siz;
				siz = 0;
			}
		}
	}
	else
	{
		for(int i =25; i >= 0; i --)
		{
            if(!siz) break;
			if(k[i] <= siz)
			{
				seg[id].c[i] = k[i];
				siz -= k[i];
				k[i] -= k[i]/2;
			}
			else
			{
				seg[id].c[i] += siz;
				k[i] -= siz;
				siz = 0;
			}
		}
	}

//        int test = 0;
//        if(L == R and L == 2)
//        {
//            for2(i,0,26) test += k[i];
//        }
//        error(test);

}
void fnd(int L,int R,int id,int l,int r)
{
	if(R < l or r < L)
		return ;
	if(l <= L and R <= r)
	{
		for2(i,0,26) k[i] += seg[id].c[i];
		return;
	}
	int mid = (L+R)/2;
	if(seg[id].lazy)
        laz(L,R,id);
	fnd(L,mid,id*2,l,r);
	fnd(mid+1,R,id*2+1,l,r);
    for2(i,0,26) seg[id].c[i] = seg[id*2].c[i] + seg[id*2+1].c[i];
}

void change(int L,int R,int id,int l,int r,bool rtl)
{
	if(R < l or r < L) return;
	if(l <= L and R <= r)
	{
		if(rtl) seg[id].sor = -1;
		else    seg[id].sor =  1;
		seg[id].lazy = 1;

//        int test = 0;
//        if(L == R and L == 2)
//        {
//            for2(i,0,26) test += k[i];
//        }
//        error(test);

		pour(id,rtl,R-L+1);

//		int deb = 0;
//		for2(i,0,26)
//		{ deb += seg[id].c[i];};
//		error(deb);
//		error(L);
//		error(R);

		return;
	}
	int mid = (L+R)/2;

	if(seg[id].lazy){
//        error(":/");
        laz(L,R,id);
    }
	if(rtl)
		change(mid+1,R,id*2+1,l,r,rtl);
	change(L,mid,id*2,l,r,rtl);
	if(!rtl)
		change(mid+1,R,id*2+1,l,r,rtl);
    for2(i,0,26) seg[id].c[i] = seg[id*2].c[i] + seg[id*2+1].c[i];
}

void prin(int l,int r,int id)
{
    if(l == r) {
        for2(i,0,26)
        if(seg[id].c[i])
        {
            cout << char(i+'a');
        }
        return;
    }

	if(seg[id].lazy)
        laz(l,r,id);
    int mid = (l+r)/2;
    prin(l,mid,id*2);
    prin(mid+1,r,id*2+1);
}

main()
{
	IOS;
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	cin >> n >> m;
	while(SZ < n) SZ *= 2;
	add();
	for2(i,0,m)
	{
		int l,r;
		cin >> l >> r;
		l --, r--;
		fill(k,k+30,0);
		int qyr = 0;
		fnd(0,SZ-1,1,l,r);

//        int test = 0;
//        if(L == R and L == 2)
//        {
//            for2(i,0,26) test += k[i];
//        }
//        error(test);

//		for2(j,0,26) qyr += seg[1].c[j];
//		error(qyr);

		int t = 0;
		for2(j,0,26){ t += k[j] % 2;}
		if(t > 1) continue ;
		int mid = (l+r)/2;
		if(t == 1){
            qwer = 1;
            change(0,SZ-1,1,mid,mid,0);
            qwer = 0;
            change(0,SZ-1,1,l,mid-1,0);
            change(0,SZ-1,1,mid+1,r,1);
        }
        else
        {
            change(0,SZ-1,1,l,mid,0);
            change(0,SZ-1,1,mid+1,r,1);
        }

/**
		qyr = 0;
		for2(j,0,26) qyr += seg[1].c[j];
		error(qyr);
		qyr = 0;
		for2(j,0,26) qyr += k[j];
		error(qyr);*/

	}
    prin(0,SZ-1,1);
}


#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define l (mid * 2)
#define r (mid * 2 + 1)
#define mp make_pair
#define timer printf("\n%lf seconds.\n", (double)clock() / CLOCKS_PER_SEC)
#define d1(x) cerr<<#x<<":"<<x<<endl;
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
using namespace std;
typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef string string;

const int N = (int)(1e5 + 5);
const int LOG = (int)(20);
const int AL = (int)(26);

int n, m;
string s;

class segment_tree
{
public:
	int tree[N << 2], lazy[N << 2], q;

	segment_tree()
	{
		memset(tree, 0, sizeof tree);
		memset(lazy, -1, sizeof lazy);
	}

	void push(int ind, int x, int y)
	{
		if(lazy[ind] == -1)
			return;

		tree[ind] = lazy[ind] * (y - x + 1);

		if(x != y)
		{
			lazy[l] = lazy[ind];
			lazy[r] = lazy[ind];
		}

		lazy[ind] = -1;

	}

	void update(int ind, int x, int y, int a, int b, int val)
	{
		push(ind, x, y);

		if(b < x || a > y)
			return;

		if(a <= x && b >= y)
		{
			lazy[ind] = val;
			push(ind, x, y);
			return;
		}

		update(l, x, mid, a, b, val);
		update(r, mid + 1, y, a, b, val);
		tree[ind] = tree[l] + tree[r];
	}

	int get(int ind, int x, int y, int a, int b)
	{
		push(ind, x, y);

		if(b < x || a > y)
			return 0;

		if(a <= x && b >= y)
			return tree[ind];

		return get(l, x, mid, a, b) + get(r, mid + 1, y, a, b);
	}

}st[AL];

bool valid(int x, int y)
{
	int oddn = 0;
	for(int i = 0; i < AL; i++)
	{
		int get = st[i].get(1, 1, n, x, y);
		if(get % 2 == 1)
			oddn++;
		if(oddn >= 2)
			return false;
	}
	return true;
}

void updstr(int x, int y)
{
	if(!valid(x, y))
		return;

	int offl = x, offr = y;

	for(int i = 0; i < AL; i++)
	{
		int getn = st[i].get(1, 1, n, x, y);

		if(getn == 0)
			continue;

		st[i].update(1, 1, n, x, y, 0);

		if(getn % 2 == 1)
			st[i].update(1, 1, n, mid, mid, 1);

		int upl = offl + getn / 2 - 1, upr = offr - getn / 2 + 1;

		st[i].update(1, 1, n, offl, upl, 1);
		st[i].update(1, 1, n, upr, offr, 1);

		offl = upl + 1;
		offr = upr - 1;
	}
}

int main()
{
	// freopen("inp.in", "r", stdin);
	// freopen("out.out", "w", stdout);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	cin >> n >> m;
	cin >> s;

	for(int i = 0; i < s.length(); i++)
		st[s[i] - 'a'].update(1, 1, n, i + 1, i + 1, 1);

	for(int i = 1; i <= m; i++)
	{
		int a, b;
		cin >> a >> b;
		updstr(a, b);
	}

	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j < AL; j++)
		{
			int get = st[j].get(1, 1, n, i, i);
			if(get == 1)
			{
				cout << (char)(j + 'a');
				break;
			}
		}
	}
}


# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define CF
struct st
{
    int m[26];
    st(void)
    {
        memset(m,0,sizeof(m));
    };
};
st operator + (st a,st b)
{
    st c;
    for (int i = 0;i < 26;++i)
        c.m[i] = a.m[i] + b.m[i];
    return c;
}
void operator += (st &a,st b)
{
    a = a + b;
}
st t[1 << 20];
int lll[1 << 20];
char s[1 << 20];
void build(int p,int u,int node)
{
    lll[node] = -1;
    if (p == u) t[node].m[s[p] - 'a'] = 1;
    else
    {
        int m = (p + u) / 2;
        build(p,m,node << 1);
        build(m + 1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
void lazy(int p,int u,int node)
{
    if (lll[node] == -1) return;
    memset(t[node].m,0,sizeof(t[node].m));
    t[node].m[lll[node]] = u - p + 1;
    if (p != u)
        lll[node << 1] = lll[node << 1 | 1] = lll[node];
    lll[node] = -1;
}
void update(int p,int u,int l,int r,int v,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) lll[node] = v;
    else
    {
        int m = (p + u) / 2;
        if (l <= m) update(p,m,l,r,v,node << 1);
        else lazy(p,m,node << 1);
        if (m+1<=r) update(m+1,u,l,r,v,node << 1 | 1);
        else lazy(m+1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
st query(int p,int u,int l,int r,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) return t[node];
    int m = (p + u) / 2;
    st ans;
    if (l <= m) ans += query(p,m,l,r,node << 1);
    if (m+1<=r) ans += query(m+1,u,l,r,node << 1 | 1);
    return ans;
}
void go(int p,int u,int node)
{
    lazy(p,u,node);
    if (p == u)
    {
        for (int i = 0;i < 26;++i)
            if (t[node].m[i])
                s[p] = char(i + 'a');
    }
    else
    {
        int m = (p + u) / 2;
        go(p,m,node << 1);
        go(m + 1,u,node << 1 | 1);
    }
}
int main(void)
{
    #ifdef CF
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    IOS;
    fi>>n>>m;
    fi>>(s + 1);
    build(1,n,1);
    while (m --)
    {
        int l,r;
        fi>>l>>r;
        auto T = query(1,n,l,r,1);
        int cnt = 0;
        for (int i = 0;i < 26;++i)
            cnt += T.m[i] & 1;
        if (cnt > 1) continue;
        if (cnt == 1)
        {
            int m = (l + r + 1) / 2;
            for (int i = 0;i < 26;++i)
                if (T.m[i]&1)
                    cnt = i;
            update(1,n,m,m,cnt,1);
            --T.m[cnt];
        }
        for (int i = 0;i < 26;++i)
            if (T.m[i] > 1)
            {
                const int cur = T.m[i] / 2 - 1;
                update(1,n,l,l + cur,i,1);
                update(1,n,r - cur,r,i,1);
                l += cur;++l;
                r -= cur;--r;
            }
    }
    go(1,n,1);
    fo << (s + 1) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define CF
struct st
{
    int m[26];
    st(void)
    {
        memset(m,0,sizeof(m));
    };
};
st operator + (st a,st b)
{
    st c;
    for (int i = 0;i < 26;++i)
        c.m[i] = a.m[i] + b.m[i];
    return c;
}
void operator += (st &a,st b)
{
    a = a + b;
}
st t[1 << 20];
int lll[1 << 20];
char s[1 << 20];
void build(int p,int u,int node)
{
    lll[node] = -1;
    if (p == u) t[node].m[s[p] - 'a'] = 1;
    else
    {
        int m = (p + u) / 2;
        build(p,m,node << 1);
        build(m + 1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
void lazy(int p,int u,int node)
{
    if (lll[node] == -1) return;
    memset(t[node].m,0,sizeof(t[node].m));
    t[node].m[lll[node]] = u - p + 1;
    if (p != u)
        lll[node << 1] = lll[node << 1 | 1] = lll[node];
    lll[node] = -1;
}
void update(int p,int u,int l,int r,int v,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) lll[node] = v;
    else
    {
        int m = (p + u) / 2;
        if (l <= m) update(p,m,l,r,v,node << 1);
        else lazy(p,m,node << 1);
        if (m+1<=r) update(m+1,u,l,r,v,node << 1 | 1);
        else lazy(m+1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
st query(int p,int u,int l,int r,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) return t[node];
    int m = (p + u) / 2;
    st ans;
    if (l <= m) ans += query(p,m,l,r,node << 1);
    if (m+1<=r) ans += query(m+1,u,l,r,node << 1 | 1);
    return ans;
}
void go(int p,int u,int node)
{
    lazy(p,u,node);
    if (p == u)
    {
        for (int i = 0;i < 26;++i)
            if (t[node].m[i])
                s[p] = char(i + 'a');
    }
    else
    {
        int m = (p + u) / 2;
        go(p,m,node << 1);
        go(m + 1,u,node << 1 | 1);
    }
}
int main(void)
{
    #ifdef CF
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    IOS;
    fi>>n>>m;
    fi>>(s + 1);
    build(1,n,1);
    while (m --)
    {
        int l,r;
        fi>>l>>r;
        auto T = query(1,n,l,r,1);
        int cnt = 0;
        int sum = 0;
        for (int i = 0;i < 26;++i)
            sum += T.m[i];
        assert(sum == r - l + 1);
        for (int i = 0;i < 26;++i)
            cnt += T.m[i] & 1;
        if (cnt > 1) continue;
        if (cnt == 1)
        {
            int m = (l + r + 1) / 2;
            for (int i = 0;i < 26;++i)
                if (T.m[i]&1)
                    cnt = i;
            update(1,n,m,m,cnt,1);
            --T.m[cnt];
        }
        for (int i = 0;i < 26;++i)
            if (T.m[i] > 1)
            {
                const int cur = T.m[i] / 2 - 1;
                update(1,n,l,l + cur,i,1);
                update(1,n,r - cur,r,i,1);
                l += cur;++l;
                r -= cur;--r;
            }
    }
    go(1,n,1);
    fo << (s + 1) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define CF
struct st
{
    int m[26];
    st(void)
    {
        memset(m,0,sizeof(m));
    };
};
st operator + (st a,st b)
{
    st c;
    for (int i = 0;i < 26;++i)
        c.m[i] = a.m[i] + b.m[i];
    return c;
}
void operator += (st &a,st b)
{
    a = a + b;
}
st t[1 << 20];
int lll[1 << 20];
char s[1 << 20];
void build(int p,int u,int node)
{
    lll[node] = -1;
    if (p == u) t[node].m[s[p] - 'a'] = 1;
    else
    {
        int m = (p + u) / 2;
        build(p,m,node << 1);
        build(m + 1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
void lazy(int p,int u,int node)
{
    if (lll[node] == -1) return;
    memset(t[node].m,0,sizeof(t[node].m));
    t[node].m[lll[node]] = u - p + 1;
    if (p != u)
        lll[node << 1] = lll[node << 1 | 1] = lll[node];
    lll[node] = -1;
}
void update(int p,int u,int l,int r,int v,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) lll[node] = v;
    else
    {
        int m = (p + u) / 2;
        if (l <= m) update(p,m,l,r,v,node << 1);
        else lazy(p,m,node << 1);
        if (m+1<=r) update(m+1,u,l,r,v,node << 1 | 1);
        else lazy(m+1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
st query(int p,int u,int l,int r,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) return t[node];
    int m = (p + u) / 2;
    st ans;
    if (l <= m) ans += query(p,m,l,r,node << 1);
    if (m+1<=r) ans += query(m+1,u,l,r,node << 1 | 1);
    return ans;
}
void go(int p,int u,int node)
{
    lazy(p,u,node);
    if (p == u)
    {
        for (int i = 0;i < 26;++i)
            if (t[node].m[i])
                s[p] = char(i + 'a');
    }
    else
    {
        int m = (p + u) / 2;
        go(p,m,node << 1);
        go(m + 1,u,node << 1 | 1);
    }
}
int main(void)
{
    #ifdef CF
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    IOS;
    fi>>n>>m;
    fi>>(s + 1);
    build(1,n,1);
    while (m --)
    {
        int l,r;
        fi>>l>>r;
        auto T = query(1,n,l,r,1);
        int cnt = 0;
        for (int i = 0;i < 26;++i)
            cnt += T.m[i] & 1;
        if (cnt > 1) continue;
        if (cnt == 1)
        {
            int m = (l + r + 1) / 2;
            for (int i = 0;i < 26;++i)
                if (T.m[i]&1)
                    cnt = i;
            update(1,n,m,m,cnt,1);
            --T.m[cnt];
        }
        for (int i = 0;i < 26;++i)
            if (T.m[i] > 0)
            {
                const int cur = T.m[i] / 2 - 1;
                update(1,n,l,l + cur,i,1);
                update(1,n,r - cur,r,i,1);
                l += cur;++l;
                r -= cur;--r;
            }
    }
    go(1,n,1);
    fo << (s + 1) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define CF
struct st
{
    int m[26];
    st(void)
    {
        memset(m,0,sizeof(m));
    };
};
st operator + (st a,st b)
{
    st c;
    for (int i = 0;i < 26;++i)
        c.m[i] = a.m[i] + b.m[i];
    return c;
}
void operator += (st &a,st b)
{
    a = a + b;
}
st t[1 << 20];
int lll[1 << 20];
char s[1 << 20];
void build(int p,int u,int node)
{
    lll[node] = -1;
    if (p == u) t[node].m[s[p] - 'a'] = 1;
    else
    {
        int m = (p + u) / 2;
        build(p,m,node << 1);
        build(m + 1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
void lazy(int p,int u,int node)
{
    if (lll[node] == -1) return;
    memset(t[node].m,0,sizeof(t[node].m));
    t[node].m[lll[node]] = u - p + 1;
    if (p != u)
        lll[node << 1] = lll[node << 1 | 1] = lll[node];
    lll[node] = -1;
}
void update(int p,int u,int l,int r,int v,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) lll[node] = v;
    else
    {
        int m = (p + u) / 2;
        if (l <= m) update(p,m,l,r,v,node << 1);
        else lazy(p,m,node << 1);
        if (m+1<=r) update(m+1,u,l,r,v,node << 1 | 1);
        else lazy(m+1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
st query(int p,int u,int l,int r,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) return t[node];
    int m = (p + u) / 2;
    st ans;
    if (l <= m) ans += query(p,m,l,r,node << 1);
    if (m+1<=r) ans += query(m+1,u,l,r,node << 1 | 1);
    return ans;
}
void go(int p,int u,int node)
{
    lazy(p,u,node);
    if (p == u)
    {
        for (int i = 0;i < 26;++i)
            if (t[node].m[i])
                s[p] = char(i + 'a');
    }
    else
    {
        int m = (p + u) / 2;
        go(p,m,node << 1);
        go(m + 1,u,node << 1 | 1);
    }
}
int main(void)
{
    #ifdef CF
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    IOS;
    fi>>n>>m;
    fi>>(s + 1);
    build(1,n,1);
    while (m --)
    {
        int l,r;
        fi>>l>>r;
        auto T = query(1,n,l,r,1);
        int cnt = 0;
        for (int i = 0;i < 26;++i)
            cnt += T.m[i] & 1;
        if (cnt > 1) continue;
        for (int i = 0;i < 26;++i)
            if (T.m[i] > 1)
            {
                const int cur = T.m[i] / 2 - 1;
                update(1,n,l,l + cur,i,1);
                update(1,n,r - cur,r,i,1);
                l += cur;++l;
                r -= cur;--r;
            }
        for (int i = 0;i < 26;++i)
            if (T.m[i] & 1)
                update(1,n,l,r,i,1);
    }
    go(1,n,1);
    fo << (s + 1) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define CF
struct st
{
    int m[26];
    st(void)
    {
        memset(m,0,sizeof(m));
    };
};
st operator + (st a,st b)
{
    st c;
    for (int i = 0;i < 26;++i)
        c.m[i] = a.m[i] + b.m[i];
    return c;
}
void operator += (st &a,st b)
{
    a = a + b;
}
st t[1 << 20];
int lll[1 << 20];
char s[1 << 20];
void build(int p,int u,int node)
{
    lll[node] = -1;
    if (p == u) t[node].m[s[p] - 'a'] = 1;
    else
    {
        int m = (p + u) / 2;
        build(p,m,node << 1);
        build(m + 1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
void lazy(int p,int u,int node)
{
    if (lll[node] == -1) return;
    memset(t[node].m,0,sizeof(t[node].m));
    t[node].m[lll[node]] = u - p + 1;
    if (p != u)
        lll[node << 1] = lll[node << 1 | 1] = lll[node];
    lll[node] = -1;
}
void update(int p,int u,int l,int r,int v,int node)
{
    if (l > r) return ;
    lazy(p,u,node);
    if (l <= p && u <= r) lll[node] = v;
    else
    {
        int m = (p + u) / 2;
        if (l <= m) update(p,m,l,r,v,node << 1);
        else lazy(p,m,node << 1);
        if (m+1<=r) update(m+1,u,l,r,v,node << 1 | 1);
        else lazy(m+1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
st query(int p,int u,int l,int r,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) return t[node];
    int m = (p + u) / 2;
    st ans;
    if (l <= m) ans += query(p,m,l,r,node << 1);
    if (m+1<=r) ans += query(m+1,u,l,r,node << 1 | 1);
    return ans;
}
void go(int p,int u,int node)
{
    lazy(p,u,node);
    if (p == u)
    {
        for (int i = 0;i < 26;++i)
            if (t[node].m[i])
                s[p] = char(i + 'a');
    }
    else
    {
        int m = (p + u) / 2;
        go(p,m,node << 1);
        go(m + 1,u,node << 1 | 1);
    }
}
int main(void)
{
    #ifdef CF
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    IOS;
    fi>>n>>m;
    fi>>(s + 1);
    build(1,n,1);
    while (m --)
    {
        int l,r;
        fi>>l>>r;
        auto T = query(1,n,l,r,1);
        int cnt = 0;
        int sum = 0;
        for (int i = 0;i < 26;++i)
            sum += T.m[i];
        assert(sum == r - l + 1);
        for (int i = 0;i < 26;++i)
            cnt += T.m[i] & 1;
        if (cnt > 1) continue;
        if (cnt == 1)
        {
            int m = (l + r + 1) / 2;
            for (int i = 0;i < 26;++i)
                if (T.m[i]&1)
                    cnt = i;
            update(1,n,m,m,cnt,1);
            --T.m[cnt];
        }
        for (int i = 0;i < 26;++i)
            if (T.m[i] > 1)
            {
                const int cur = T.m[i] / 2 - 1;
                update(1,n,l,l + cur,i,1);
                update(1,n,r - cur,r,i,1);
                l += cur;++l;
                r -= cur;--r;
            }
    }
    go(1,n,1);
    fo << (s + 1) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define CF
struct st
{
    int m[26];
    st(void)
    {
        memset(m,0,sizeof(m));
    };
};
st operator + (st a,st b)
{
    st c;
    for (int i = 0;i < 26;++i)
        c.m[i] = a.m[i] + b.m[i];
    return c;
}
void operator += (st &a,st b)
{
    a = a + b;
}
st t[1 << 20];
int lll[1 << 20];
char s[1 << 20];
void build(int p,int u,int node)
{
    lll[node] = -1;
    if (p == u) t[node].m[s[p] - 'a'] = 1;
    else
    {
        int m = (p + u) / 2;
        build(p,m,node << 1);
        build(m + 1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
void lazy(int p,int u,int node)
{
    if (lll[node] == -1) return;
    memset(t[node].m,0,sizeof(t[node].m));
    t[node].m[lll[node]] = u - p + 1;
    if (p != u)
        lll[node << 1] = lll[node << 1 | 1] = lll[node];
    lll[node] = -1;
}
void update(int p,int u,int l,int r,int v,int node)
{
    if (l > r) return ;
    lazy(p,u,node);
    if (l <= p && u <= r) lll[node] = v;
    else
    {
        int m = (p + u) / 2;
        if (l <= m) update(p,m,l,r,v,node << 1);
        lazy(p,m,node << 1);
        if (m+1<=r) update(m+1,u,l,r,v,node << 1 | 1);
        lazy(m+1,u,node << 1 | 1);
        t[node] = t[node << 1] + t[node << 1 | 1];
    }
}
st query(int p,int u,int l,int r,int node)
{
    lazy(p,u,node);
    if (l <= p && u <= r) return t[node];
    int m = (p + u) / 2;
    st ans;
    if (l <= m) ans += query(p,m,l,r,node << 1);
    if (m+1<=r) ans += query(m+1,u,l,r,node << 1 | 1);
    return ans;
}
void go(int p,int u,int node)
{
    lazy(p,u,node);
    if (p == u)
    {
        for (int i = 0;i < 26;++i)
            if (t[node].m[i])
                s[p] = char(i + 'a');
    }
    else
    {
        int m = (p + u) / 2;
        go(p,m,node << 1);
        go(m + 1,u,node << 1 | 1);
    }
}
int main(void)
{
    #ifdef CF
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    IOS;
    fi>>n>>m;
    fi>>(s + 1);
    build(1,n,1);
    while (m --)
    {
        int l,r;
        fi>>l>>r;
        auto T = query(1,n,l,r,1);
        int cnt = 0;
        int sum = 0;
        for (int i = 0;i < 26;++i)
            sum += T.m[i];
        assert(sum == r - l + 1);
        for (int i = 0;i < 26;++i)
            cnt += T.m[i] & 1;
        if (cnt > 1) continue;
        if (cnt == 1)
        {
            int m = (l + r + 1) / 2;
            for (int i = 0;i < 26;++i)
                if (T.m[i]&1)
                    cnt = i;
            update(1,n,m,m,cnt,1);
            --T.m[cnt];
        }
        for (int i = 0;i < 26;++i)
            if (T.m[i] > 1)
            {
                const int cur = T.m[i] / 2 - 1;
                update(1,n,l,l + cur,i,1);
                update(1,n,r - cur,r,i,1);
                l += cur;++l;
                r -= cur;--r;
            }
    }
    go(1,n,1);
    fo << (s + 1) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}