#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)

#define INF 987654321
#define IINF 2987654321987654321
#define MOD 1000000007

const int MAXN = 1e5 + 50;
int tree[26][4*MAXN], lazy[26][4*MAXN], len[4*MAXN], n;
void pushDown(int x, int id) {
	if(lazy[x][id] == 1) {
		tree[x][2*id] = len[2*id];
		tree[x][2*id+1] = len[2*id+1];
		lazy[x][2*id] = lazy[x][2*id+1] = 1;
	} else if(lazy[x][id] == 0) {
		tree[x][2*id] = tree[x][2*id+1] = 0;
		lazy[x][2*id] = lazy[x][2*id+1] = 0;
	}
	lazy[x][id] = -1;
}

void pushUp(int x, int id) {
	tree[x][id] = tree[x][2*id] + tree[x][2*id+1];
}

void buildTree(char *s, int x, int l = 1, int r = n, int id = 1) {
	if(l == r) {
		len[id] = 1;
		tree[x][id] = (s[l]-'a' == x) ? 1 : 0;
		return;
	}
	len[id] = r-l+1;
	int mid = (l + r) / 2;
	buildTree(s, x, l, mid, 2*id);
	buildTree(s, x, mid+1, r, 2*id+1);
	pushUp(x, id);
}

void rangeUpdate(int x, int s, int e, int val, int l = 1, int r = n, int id = 1) {
	if(r < s || e < l) return;
	if(s <= l && r <= e) {
		tree[x][id] = len[id] * val;
		lazy[x][id] = val;
		return;
	}
	int mid = (l + r) / 2;
	pushDown(x, id);
	rangeUpdate(x, s, e, val, l, mid, 2*id);
	rangeUpdate(x, s, e, val, mid+1, r, 2*id+1);
	pushUp(x, id);
}

int rangeSum(int x, int s, int e, int l = 1, int r = n, int id = 1) {
	if(r < s || e < l) return 0;
	if(s <= l && r <= e) return tree[x][id];
	int mid = (l + r) / 2;
	pushDown(x, id);
	int res = rangeSum(x, s, e, l, mid, 2*id) + rangeSum(x, s, e, mid+1, r, 2*id+1);
	pushUp(x, id);
	return res;
}

void query(char *s, int l, int r) {
	vector<int> cnt(26, 0);
	rep(x, 26) cnt[x] = rangeSum(x, l, r);
	int odd = 0, oi = -1;
	rep(x, 26) if(cnt[x]&1) odd++, oi = x;
	if(odd > 1) return;

	rep(x, 26) rangeUpdate(x, l, r, 0);
	int p = l;
	rep(x, 26) if(cnt[x]) {
		rangeUpdate(x, p, p + cnt[x]/2 - 1, 1);
		p += cnt[x]/2;
	}
	if(oi != -1) {
		rangeUpdate(oi, p, p, 1);
		p++;
	}
	for(int x = 25; x >= 0; x--) if(cnt[x]) {
		rangeUpdate(x, p, p + cnt[x]/2 - 1, 1);
		p += cnt[x]/2;
	}
}

void restore(char *s, int l = 1, int r = n, int id = 1) {
	if(l == r) {
		rep(x, 26) if(tree[x][id]) s[l] = 'a'+x;
		return;
	}
	int mid = (l + r) / 2;
	rep(x, 26) pushDown(x, id);
	restore(s, l, mid, 2*id);
	restore(s, mid+1, r, 2*id+1);
	rep(x, 26) pushUp(x, id);
}

char s[MAXN];
int main() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	memset(lazy, -1, sizeof lazy);

	int q;
	scanf("%d%d%s", &n, &q, s+1);
	rep(x, 26) buildTree(s, x);

	while(q--) {
		int l, r; scanf("%d%d", &l, &r);
		query(s, l, r);
		//printf("%s\n", s+1);
	}
	restore(s);
	printf("%s\n", s+1);
}


#include <bits/stdc++.h>

using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#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;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2

const long long LINF = 1e18+5;
const int MOD = (int) 1e9 + 7;
const int LOG = 18;
const int INF = 1e9;
const int N = 1e5+5;
const int M = 350;
const int ALP = 26;
const int SQ = 350;

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;

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

		segment_tree() {

			memset(lazy , -1 , sizeof lazy);
			memset(sum , 0 , sizeof sum);

		}

		void push(int ind,int l, int r) {
			if(lazy[ind] == -1)
				return;
			sum[ind] = lazy[ind] * (r - l + 1);
			if(l != r) {
				lazy[left] = lazy[ind];
				lazy[right] = lazy[ind];
			}

			lazy[ind] = -1;

		}

		void update(int ind ,int l,int r ,int lw,int rw,int val) {

			push(ind,l,r);
			if(l > rw || r < lw)
				return;
			if (l >= lw && r <= rw) {
				lazy[ind] = val;
				push(ind,l,r);
				return ;
			}
			update(left,l,mid,lw,rw,val);
			update(right,mid + 1,r,lw,rw,val);
			sum[ind] = sum[left] + sum[right];

		}

		int get(int ind,int l,int r,int lw,int rw) {

			push(ind,l,r);
			if(l > rw || r < lw)
				return 0;
			if (l >= lw && r <= rw)
				return sum[ind];
			return get(left,l,mid,lw,rw) + get(right,mid + 1,r,lw,rw);

		}

}tree[ALP];

int n,m;

bool check(int l,int r) {

	int ret = 0;
	for(int i = 0 ; i < ALP ; i++) {
		if(tree[i].get(1,1,n,l,r) & 1)
			ret++;
	}
	return ret < 2;

}

void up(int l,int r) {

	if(check(l,r) == false)
		return ;
	int odd = -1,tutl = l,tutr = r;
	for(int i = 0 ; i < ALP ; i++) {
		int tut = tree[i].get(1,1,n,tutl,tutr);
		tree[i].update(1,1,n,tutl,tutr,0);
		if(tut & 1) {
			odd = i;
		}
		if(tut < 2)
			continue;
		tree[i].update(1,1,n,l,l + tut / 2 - 1,1);
		tree[i].update(1,1,n,r - tut / 2 + 1,r,1);
		l += tut/2;
		r -= tut/2;
	}
	if(odd != -1)
		tree[odd].update(1,1,n,l,r,1);

}

int main() {

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	scanf("%d %d",&n,&m);
	for (int i = 1 ; i <= n ; i++) {
		char c;
		scanf(" %c",&c);
		tree[c - 'a'].update(1,1,n,i,i,1);
	}

	while(m--) {
		int l ,r;
		scanf("%d %d",&l,&r);
		up(l,r);
	}

	for (int i = 1 ; i <= n ; i++) {
		for (int j = 0 ; j < ALP ; j++) {
			if(tree[j].get(1,1,n,i,i)) {
				printf("%c", j + 'a');
				break;
			}
		}
	}

	return 0 ;
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

int t[N * 4][30], z[N * 4][30];

inline void push(int v, int tl, int tr, int c) {
    if (z[v][c] != -1) {
        t[v][c] = z[v][c] * (tr - tl + 1);
        if (tl != tr) {
            z[v * 2][c] = z[v * 2 + 1][c] = z[v][c];
        }
        z[v][c] = -1;
    }
}

inline void upd(int v, int tl, int tr, int l, int r, int c, int val) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return;
    if (tl >= l && tr <= r) {
        z[v][c] = val;
        push(v, tl, tr, c);
        return;
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    upd(v * 2, tl, tm, l, r, c, val);
    upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
    t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
}

int get(int v, int tl, int tr, int l, int r, int c) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return 0;
    if (tl >= l && tr <= r) {
        push(v, tl, tr, c);
        return t[v][c];
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
}

int can(int l, int r) {
    int cnt = 0;
    if (l == r)
        return 0;
    for (int i = 1; i <= 26; ++i) {
        int x = get(1, 1, n, l, r, i);
        if (x % 2 == 1 && (r - l + 1) % 2 == 0)
            return 0;
        if (x % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

inline void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = get(1, 1, n, l, r, i);
        upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1) {
            ch = i;
        }
        cnt >>= 1;
        upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1)
        upd(1, 1, n, md, md, ch, 1);
}

inline void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (get(1, 1, n, i, i, j)) {
                printf("%c", char(j + 'a' - 1));
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    cin >> s;
    for (int i = 1; i <= n; ++i)
        upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

struct tree {
    int t[N * 4][30], z[N * 4][30];
    inline void push(int v, int tl, int tr, int c) {
        if (z[v][c] != -1) {
            t[v][c] = z[v][c];
            if (tl != tr) {
                z[v * 2][c] = z[v][c];
                z[v * 2 + 1][c] = z[v][c];
            }
            z[v][c] = -1;
        }
    }
    inline void upd(int v, int tl, int tr, int l, int r, int c, int val) {
        push(v, tl, tr, c);
        if (tl > r || tr < l)
            return;
        if (tl >= l && tr <= r) {
            z[v][c] = val;
            push(v, tl, tr, c);
            return;
        }
        push(v, tl, tr, c);
        int tm = (tl + tr) / 2;
        upd(v * 2, tl, tm, l, r, c, val);
        upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
        t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
    }
    int get(int v, int tl, int tr, int l, int r, int c) {
        push(v, tl, tr, c);
        if (tl > r || tr < l)
            return 0;
        if (tl >= l && tr <= r)
            return t[v][c];
        push(v, tl, tr, c);
        int tm = (tl + tr) / 2;
        return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
    }
} t;

int can(int l, int r) {
    if (l == r)
        return 0;
    int cnt = 0;
    for (int i = 1; i <= 26; ++i) {
        int x = t.get(1, 1, n, l, r, i);
        if ((r - l + 1) % 2 == 0 && x % 2 == 1)
            return 0;
        if ((r - l + 1) % 2 == 1 && x % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

inline void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = t.get(1, 1, n, l, r, i);
        t.upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1)
            ch = i;
        cnt >>= 1;
        t.upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        t.upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1) {
        t.upd(1, 1, n, md, md, ch, 1);
    }

}

inline void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (t.get(1, 1, n, i, i, j)) {
                cout << char(j + 'a' - 1);
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> s;
    for (int i = 1; i <= n; ++i)
        t.upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        cin >> l >> r;
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

int t[N * 4][30], z[N * 4][30];

void push(int v, int tl, int tr, int c) {
    if (z[v][c] != -1) {
        t[v][c] = z[v][c] * (tr - tl + 1);
        if (tl != tr) {
            z[v * 2][c] = z[v * 2 + 1][c] = z[v][c];
        }
        z[v][c] = -1;
    }
}

void upd(int v, int tl, int tr, int l, int r, int c, int val) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return;
    if (tl >= l && tr <= r) {
        z[v][c] = val;
        push(v, tl, tr, c);
        return;
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    upd(v * 2, tl, tm, l, r, c, val);
    upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
    t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
}

int get(int v, int tl, int tr, int l, int r, int c) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return 0;
    if (tl >= l && tr <= r) {
        push(v, tl, tr, c);
        return t[v][c];
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
}

int can(int l, int r) {
    int cnt = 0;
    if (l == r)
        return 0;
    for (int i = 1; i <= 26; ++i) {
        if (get(1, 1, n, l, r, i) % 2 == 1 && (r - l + 1) % 2 == 0)
            return 0;
        if (get(1, 1, n, l, r, i) % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = get(1, 1, n, l, r, i);
        upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1) {
            ch = i;
        }
        cnt /= 2;
        upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1)
        upd(1, 1, n, md, md, ch, 1);
}

void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (get(1, 1, n, i, i, j)) {
                cout << char(j + 'a' - 1);
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> s;
    for (int i = 1; i <= n; ++i)
        upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        cin >> l >> r;
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

int t[N * 4][30], z[N * 4][30];

void push(int v, int tl, int tr, int c) {
    if (z[v][c] != -1) {
        t[v][c] = z[v][c] * (tr - tl + 1);
        if (tl != tr) {
            z[v * 2][c] = z[v * 2 + 1][c] = z[v][c];
        }
        z[v][c] = -1;
    }
}

void upd(int v, int tl, int tr, int l, int r, int c, int val) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return;
    if (tl >= l && tr <= r) {
        z[v][c] = val;
        push(v, tl, tr, c);
        return;
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    upd(v * 2, tl, tm, l, r, c, val);
    upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
    t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
}

int get(int v, int tl, int tr, int l, int r, int c) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return 0;
    if (tl >= l && tr <= r) {
        push(v, tl, tr, c);
        return t[v][c];
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
}

int can(int l, int r) {
    int cnt = 0;
    if (l == r)
        return 0;
    for (int i = 1; i <= 26; ++i) {
        if (get(1, 1, n, l, r, i) % 2 == 1 && (r - l + 1) % 2 == 0)
            return 0;
        if (get(1, 1, n, l, r, i) % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = get(1, 1, n, l, r, i);
        upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1) {
            ch = i;
        }
        cnt /= 2;
        upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1)
        upd(1, 1, n, md, md, ch, 1);
}

void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (get(1, 1, n, i, i, j)) {
                cout << char(j + 'a' - 1);
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> n >> m >> s;
    for (int i = 1; i <= n; ++i)
        upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        cin >> l >> r;
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

struct tree {
    int t[N * 4][30], z[N * 4][30];
    inline void push(int v, int tl, int tr, int c) {
        if (z[v][c] != -1) {
            t[v][c] = z[v][c] * (tr - tl + 1);
            if (tl != tr) {
                z[v * 2][c] = z[v][c];
                z[v * 2 + 1][c] = z[v][c];
            }
            z[v][c] = -1;
        }
    }
    inline void upd(int v, int tl, int tr, int l, int r, int c, int val) {
        push(v, tl, tr, c);
        if (tl > r || tr < l)
            return;
        if (tl >= l && tr <= r) {
            z[v][c] = val;
            push(v, tl, tr, c);
            return;
        }
        push(v, tl, tr, c);
        int tm = (tl + tr) / 2;
        upd(v * 2, tl, tm, l, r, c, val);
        upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
        t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
    }
    int get(int v, int tl, int tr, int l, int r, int c) {
        push(v, tl, tr, c);
        if (tl > r || tr < l)
            return 0;
        if (tl >= l && tr <= r) {
            push(v, tl, tr, c);
            return t[v][c];
        }
        push(v, tl, tr, c);
        int tm = (tl + tr) / 2;
        return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
    }
} t;

int can(int l, int r) {
    if (l == r)
        return 0;
    int cnt = 0;
    for (int i = 1; i <= 26; ++i) {
        int x = t.get(1, 1, n, l, r, i);
        if ((r - l + 1) % 2 == 0 && x % 2 == 1)
            return 0;
        if ((r - l + 1) % 2 == 1 && x % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

inline void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = t.get(1, 1, n, l, r, i);
        t.upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1)
            ch = i;
        cnt >>= 1;
        if (!cnt)
            continue;
        t.upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        t.upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1) {
        t.upd(1, 1, n, md, md, ch, 1);
    }

}

inline void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (t.get(1, 1, n, i, i, j)) {
                cout << char(j + 'a' - 1);
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> s;
    for (int i = 1; i <= n; ++i)
        t.upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        cin >> l >> r;
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

int t[N * 4][30], z[N * 4][30];

void push(int v, int tl, int tr, int c) {
    if (z[v][c] != -1) {
        t[v][c] = z[v][c] * (tr - tl + 1);
        if (tl != tr) {
            z[v * 2][c] = z[v * 2 + 1][c] = z[v][c];
        }
        z[v][c] = -1;
    }
}

void upd(int v, int tl, int tr, int l, int r, int c, int val) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return;
    if (tl >= l && tr <= r) {
        z[v][c] = val;
        push(v, tl, tr, c);
        return;
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    upd(v * 2, tl, tm, l, r, c, val);
    upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
    t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
}

int get(int v, int tl, int tr, int l, int r, int c) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return 0;
    if (tl >= l && tr <= r) {
        push(v, tl, tr, c);
        return t[v][c];
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
}

int can(int l, int r) {
    int cnt = 0;
    if (l == r)
        return 0;
    for (int i = 1; i <= 26; ++i) {
        int x = get(1, 1, n, l, r, i);
        if (x % 2 == 1 && (r - l + 1) % 2 == 0)
            return 0;
        if (x % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = get(1, 1, n, l, r, i);
        upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1) {
            ch = i;
        }
        cnt >>= 1;
        upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1)
        upd(1, 1, n, md, md, ch, 1);
}

void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (get(1, 1, n, i, i, j)) {
                printf("%c", char(j + 'a' - 1));
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    cin >> s;
    for (int i = 1; i <= n; ++i)
        upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

int t[N * 4][30], z[N * 4][30];

inline void push(int v, int tl, int tr, int c) {
    if (z[v][c] != -1) {
        t[v][c] = z[v][c] * (tr - tl + 1);
        if (tl != tr) {
            z[v * 2][c] = z[v * 2 + 1][c] = z[v][c];
        }
        z[v][c] = -1;
    }
}

inline void upd(int v, int tl, int tr, int l, int r, int c, int val) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return;
    if (tl >= l && tr <= r) {
        z[v][c] = val;
        push(v, tl, tr, c);
        return;
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    upd(v * 2, tl, tm, l, r, c, val);
    upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
    t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
}

int get(int v, int tl, int tr, int l, int r, int c) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return 0;
    if (tl >= l && tr <= r) {
        push(v, tl, tr, c);
        return t[v][c];
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
}

int can(int l, int r) {
    int cnt = 0;
    if (l == r)
        return 0;
    for (int i = 1; i <= 26; ++i) {
        int x = get(1, 1, n, l, r, i);
        if (x % 2 == 1 && (r - l + 1) % 2 == 0)
            return 0;
        if (x % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

inline void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = get(1, 1, n, l, r, i);
        upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1) {
            ch = i;
        }
        cnt >>= 1;
        upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1)
        upd(1, 1, n, md, md, ch, 1);
}

inline void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (get(1, 1, n, i, i, j)) {
                printf("%c", char(j + 'a' - 1));
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    cin >> s;
    for (int i = 1; i <= n; ++i)
        upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

struct tree {
    int t[N * 4][30], z[N * 4][30];
    inline void push(int v, int tl, int tr, int c) {
        if (z[v][c] != -1) {
            t[v][c] = z[v][c];
            if (tl != tr) {
                z[v * 2][c] = z[v][c];
                z[v * 2 + 1][c] = z[v][c];
            }
            z[v][c] = -1;
        }
    }
    inline void upd(int v, int tl, int tr, int l, int r, int c, int val) {
        push(v, tl, tr, c);
        if (tl > r || tr < l)
            return;
        if (tl >= l && tr <= r) {
            z[v][c] = val;
            push(v, tl, tr, c);
            return;
        }
        push(v, tl, tr, c);
        int tm = (tl + tr) / 2;
        upd(v * 2, tl, tm, l, r, c, val);
        upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
        t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
    }
    int get(int v, int tl, int tr, int l, int r, int c) {
        push(v, tl, tr, c);
        if (tl > r || tr < l)
            return 0;
        if (tl >= l && tr <= r) {
            push(v, tl, tr, c);
            return t[v][c];
        }
        push(v, tl, tr, c);
        int tm = (tl + tr) / 2;
        return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
    }
} t;

int can(int l, int r) {
    if (l == r)
        return 0;
    int cnt = 0;
    for (int i = 1; i <= 26; ++i) {
        int x = t.get(1, 1, n, l, r, i);
        if ((r - l + 1) % 2 == 0 && x % 2 == 1)
            return 0;
        if ((r - l + 1) % 2 == 1 && x % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

inline void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = t.get(1, 1, n, l, r, i);
        t.upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1)
            ch = i;
        cnt >>= 1;
        t.upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        t.upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1) {
        t.upd(1, 1, n, md, md, ch, 1);
    }

}

inline void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (t.get(1, 1, n, i, i, j)) {
                cout << char(j + 'a' - 1);
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> s;
    for (int i = 1; i <= n; ++i)
        t.upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        cin >> l >> r;
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

int t[N * 4][30], z[N * 4][30];

void push(int v, int tl, int tr, int c) {
    if (z[v][c] != -1) {
        t[v][c] = z[v][c] * (tr - tl + 1);
        if (tl != tr) {
            z[v * 2][c] = z[v * 2 + 1][c] = z[v][c];
        }
        z[v][c] = -1;
    }
}

void upd(int v, int tl, int tr, int l, int r, int c, int val) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return;
    if (tl >= l && tr <= r) {
        z[v][c] = val;
        push(v, tl, tr, c);
        return;
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    upd(v * 2, tl, tm, l, r, c, val);
    upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
    t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
}

int get(int v, int tl, int tr, int l, int r, int c) {
    push(v, tl, tr, c);
    if (tl > r || tr < l)
        return 0;
    if (tl >= l && tr <= r) {
        push(v, tl, tr, c);
        return t[v][c];
    }
    push(v, tl, tr, c);
    int tm = (tl + tr) / 2;
    return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
}

int can(int l, int r) {
    int cnt = 0;
    if (l == r)
        return 0;
    for (int i = 1; i <= 26; ++i) {
        int x = get(1, 1, n, l, r);
        if (x % 2 == 1 && (r - l + 1) % 2 == 0)
            return 0;
        if (x % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = get(1, 1, n, l, r, i);
        upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1) {
            ch = i;
        }
        cnt >>= 1;
        upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1)
        upd(1, 1, n, md, md, ch, 1);
}

void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (get(1, 1, n, i, i, j)) {
                printf("%c", char(j + 'a' - 1));
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    cin >> s;
    for (int i = 1; i <= n; ++i)
        upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        scnaf("%d%d", &l, &r);
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#include <bits/stdc++.h>

using namespace std;

#define _48_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, m;

string s;

struct tree {
    int t[N * 4][30], z[N * 4][30];
    inline void push(int v, int tl, int tr, int c) {
        if (z[v][c] != -1) {
            t[v][c] = z[v][c];
            if (tl != tr) {
                z[v * 2][c] = z[v][c];
                z[v * 2 + 1][c] = z[v][c];
            }
            z[v][c] = -1;
        }
    }
    inline void upd(int v, int tl, int tr, int l, int r, int c, int val) {
        push(v, tl, tr, c);
        if (tl > r || tr < l)
            return;
        if (tl >= l && tr <= r) {
            z[v][c] = val;
            push(v, tl, tr, c);
            return;
        }
        push(v, tl, tr, c);
        int tm = (tl + tr) / 2;
        upd(v * 2, tl, tm, l, r, c, val);
        upd(v * 2 + 1, tm + 1, tr, l, r, c, val);
        t[v][c] = t[v * 2][c] + t[v * 2 + 1][c];
    }
    int get(int v, int tl, int tr, int l, int r, int c) {
        push(v, tl, tr, c);
        if (tl > r || tr < l)
            return 0;
        if (tl >= l && tr <= r) {
            push(v, tl, tr, c);
            return t[v][c];
        }
        push(v, tl, tr, c);
        int tm = (tl + tr) / 2;
        return get(v * 2, tl, tm, l, r, c) + get(v * 2 + 1, tm + 1, tr, l, r, c);
    }
} t;

int can(int l, int r) {
    if (l == r)
        return 0;
    int cnt = 0;
    for (int i = 1; i <= 26; ++i) {
        int x = t.get(1, 1, n, l, r, i);
        if ((r - l + 1) % 2 == 0 && x % 2 == 1)
            return 0;
        if ((r - l + 1) % 2 == 1 && x % 2 == 1)
            ++cnt;
        if (cnt == 2)
            return 0;
    }
    return 1;
}

inline void doo(int l, int r) {
    int lastl = l, lastr = r, md = (l + r) / 2, ch = -1;
    for (int i = 1; i <= 26; ++i) {
        int cnt = t.get(1, 1, n, l, r, i);
        t.upd(1, 1, n, l, r, i, 0);
        if (cnt % 2 == 1)
            ch = i;
        cnt >>= 1;
        if (!cnt)
            continue;
        t.upd(1, 1, n, lastl, lastl + cnt - 1, i, 1);
        t.upd(1, 1, n, lastr - cnt + 1, lastr, i, 1);
        lastl += cnt;
        lastr -= cnt;
    }
    if (ch != -1) {
        t.upd(1, 1, n, md, md, ch, 1);
    }

}

inline void print() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 26; ++j) {
            if (t.get(1, 1, n, i, i, j)) {
                cout << char(j + 'a' - 1);
                break;
            }
        }
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> s;
    for (int i = 1; i <= n; ++i)
        t.upd(1, 1, n, i, i, s[i - 1] - 'a' + 1, 1);
    for (int i = 1; i <= m; ++i) {
        int l, r;
        cin >> l >> r;
        if (can(l, r)) {
            doo(l, r);
        }
    }
    print();
}


#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)/2;
  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 node, int st, int en, int l, int r, int ind)
{
  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)/2;
  return get(2*node+1,st,mid,l,r,ind)+get(2*node+2,mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind, int val)
{
  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)/2;
  update(2*node+1,st,mid,l,r,ind,val);
  update(2*node+2,mid,en,l,r,ind,val);
  data[node][ind]=data[2*node+1][ind]+data[2*node+2][ind];
}
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  #define cin fin
  #define cout fout
main()
{

  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(0,0,n,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(0,0,n,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(0,0,n,l,r,i,0);
      for(int i=1;i<=26;i++)
      {
        int wh=cnt[i]/2;
        update(0,0,n,l,l+wh,i,1);
        update(0,0,n,r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(0,0,n,l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=1;j<=26;j++)
    {
      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;
#define pb push_back
#define mp make_pair

const int maxN = 1e5 + 10;
int data[maxN][26],lazy[maxN][26],n;
//data[node][c]: jaame tedade character haye c too bazehye node
int cnt[26];

void shift(int ch, int s, int e, int id)
{
    int x = lazy[id][ch];
    if (x == -1) //chizi baraye shift dadan nadare
        return;

    int mid = s + e >> 1;

    lazy[2 * id][ch] = x;
    data[2 * id][ch] = (mid - s) * x;

    lazy[2 * id + 1][ch] = x;
    data[2 * id + 1][ch] = (e - mid) * x;

    lazy[id][ch] = -1;
}

void update(int l, int r, int ch, int val, int s = 0, int e = n, int id = 1)
{
    if (e <= l || r <= s)
        return;
    if (l <= s && e <= r)
    {
        data[id][ch] = (e - s) * val;
        lazy[id][ch] = val;
        //cout << l << " " << r << " " << data[id][ch] << " " << lazy[id][ch] << " " << char(ch + 'a') << endl;
        return;
    }

    shift(ch, s, e, id);

    int mid = s + e >> 1;
    update(l, r, ch, val, s, mid, 2 * id);
    update(l, r, ch, val, mid, e, 2 * id + 1);
    data[id][ch] = data[2 * id][ch] + data[2 * id + 1][ch];
}

int get(int l, int r, int ch, int s = 0, int e = n, int id = 1)
{
    if (e <= l || r <= s)
        return 0;
    if (l <= s && e <= r)
        return data[id][ch];
    int mid = s + e >> 1;
    shift(ch, s, e, id);
    return get(l, r, ch, s, mid, 2 * id) + get(l, r, ch, mid, e, 2 * id + 1);
}

int32_t main()
{
    for (int i = 0 ; i < maxN ; i++)
        for (int j = 0 ; j < 26 ; j++)
            lazy[i][j] = -1;

    string s;
    int q;
    cin >> n >> q >> s;
    for (int i = 0 ; i < n ; i++)
    {
        //cout << "Adding " << i << " " << i + 1 << " " << s[i] - 'a' << " " << 1 << endl;
        update(i, i + 1, s[i] - 'a', 1);
    }

    while (q--)
    {
        int l,r;
        cin >> l >> r;
        l--;
        int pos1 = l, pos2 = r;
        int odd = 0;
        char mid; //character ee ke fard bar omade bayad miad vasat
        for (int i = 0 ; i < 26 ; i++)
        {
            cnt[i] = get(l, r, i);
            if (cnt[i] & 1)
            {
                mid = i;
                odd++;
            }
        }

        if (odd > 1)
            continue;
        if ( (r - l) % 2 == 0 ) //toolesh zoj
            if (odd == 1) //hame bayad zoj bar omade bashan
                continue;

        for (int i = 0 ; i < 26 ; i++)
            update(l, r, i, 0); //paak kon hame ro az inja

        for (int i = 0 ; i < 26 ; i++)
        {
            int num = cnt[i] / 2;
            update(pos1, pos1 + num, i, 1); //num ta i bezar avvalesh
            update(pos2 - num, pos2, i, 1); //num ta i bezar akharesh
            pos1 += num;
            pos2 -= num;
        }

        if ((r - l) & 1)
            update(pos1, pos1 + 1, mid, 1);
    }

    for (int i = 0 ; i < n ; i++)
        for (int j = 0 ; j < 26 ; j++)
            if (get(i, i + 1, j) > 0)
                cout << (char)(j + 'a');
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair

const int maxN = 1e5 + 10;
int data[4 * maxN][26],lazy[4 * maxN][26],n;
//data[node][c]: jaame tedade character haye c too bazehye node
int cnt[26];

void shift(int ch, int s, int e, int id)
{
    int x = lazy[id][ch];
    if (x == -1) //chizi baraye shift dadan nadare
        return;

    int mid = s + e >> 1;

    lazy[2 * id][ch] = x;
    data[2 * id][ch] = (mid - s) * x;

    lazy[2 * id + 1][ch] = x;
    data[2 * id + 1][ch] = (e - mid) * x;

    lazy[id][ch] = -1;
}

void update(int l, int r, int ch, int val, int s = 0, int e = n, int id = 1)
{
    if (e <= l || r <= s)
        return;
    if (l <= s && e <= r)
    {
        data[id][ch] = (e - s) * val;
        lazy[id][ch] = val;
        //cout << l << " " << r << " " << data[id][ch] << " " << lazy[id][ch] << " " << char(ch + 'a') << endl;
        return;
    }

    shift(ch, s, e, id);

    int mid = s + e >> 1;
    update(l, r, ch, val, s, mid, 2 * id);
    update(l, r, ch, val, mid, e, 2 * id + 1);
    data[id][ch] = data[2 * id][ch] + data[2 * id + 1][ch];
}

int get(int l, int r, int ch, int s = 0, int e = n, int id = 1)
{
    if (e <= l || r <= s)
        return 0;
    if (l <= s && e <= r)
        return data[id][ch];
    int mid = s + e >> 1;
    shift(ch, s, e, id);
    return get(l, r, ch, s, mid, 2 * id) + get(l, r, ch, mid, e, 2 * id + 1);
}

ifstream fin ("input.txt");
ofstream fout ("output.txt");
#define cin fin
#define cout fout

int32_t main()
{
    for (int i = 0 ; i < maxN ; i++)
        for (int j = 0 ; j < 26 ; j++)
            lazy[i][j] = -1;

    string s;
    int q;
    cin >> n >> q >> s;
    for (int i = 0 ; i < n ; i++)
    {
        //cout << "Adding " << i << " " << i + 1 << " " << s[i] - 'a' << " " << 1 << endl;
        update(i, i + 1, s[i] - 'a', 1);
    }

    while (q--)
    {
        int l,r;
        cin >> l >> r;
        l--;
        int pos1 = l, pos2 = r;
        int odd = 0;
        char mid; //character ee ke fard bar omade bayad miad vasat
        for (int i = 0 ; i < 26 ; i++)
        {
            cnt[i] = get(l, r, i);
            if (cnt[i] & 1)
            {
                mid = i;
                odd++;
            }
        }

        if (odd > 1)
            continue;

        if ( (r - l) % 2 == 0 ) //toolesh zoj
            if (odd == 1) //hame bayad zoj bar omade bashan
                continue;

        for (int i = 0 ; i < 26 ; i++)
            update(l, r, i, 0); //paak kon hame ro az inja

        for (int i = 0 ; i < 26 ; i++)
        {
            if (cnt[i] == 0)
                continue;
            int num = cnt[i] / 2;
            update(pos1, pos1 + num, i, 1); //num ta i bezar avvalesh
            update(pos2 - num, pos2, i, 1); //num ta i bezar akharesh
            pos1 += num;
            pos2 -= num;
        }

        if ((r - l) & 1)
            update(pos1, pos1 + 1, mid, 1);
    }

    for (int i = 0 ; i < n ; i++)
        for (int j = 0 ; j < 26 ; j++)
            if (get(i, i + 1, j) > 0)
                cout << (char)(j + 'a');
    cout << endl;
    return 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)/2;
  helper[2*node][ind]=helper[node][ind];
  helper[2*node+1][ind]=helper[node][ind];
  data[2*node][ind]=(mid-st)*helper[node][ind];
  data[2*node+1][ind]=(en-mid)*helper[node][ind];
  helper[node][ind]=-1;
}
int get(int node, int st, int en, int l, int r, int ind)
{
  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)/2;
  return get(2*node,st,mid,l,r,ind)+get(2*node+1,mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind, int val)
{
  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)/2;
  update(2*node,st,mid,l,r,ind,val);
  update(2*node+1,mid,en,l,r,ind,val);
  data[node][ind]=data[2*node][ind]+data[2*node+1][ind];
}
main()
{
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  fin>>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(0,0,n,i,i+1,str[i]-'a'+1,1);
  while(q--)
  {
    fin>>l>>r;
    l--;
    bool odd=false,bad=false;
    for(int i=1;i<=26;i++)
    {
      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(int i=1;i<=26;i++)
        update(0,0,n,l,r,i,0);
      for(int i=1;i<=26;i++)
      {
        int wh=cnt[i]/2;
        update(0,0,n,l,l+wh,i,1);
        update(0,0,n,r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(0,0,n,l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=1;j<=26;j++)
    {
      char help='a';
      if(get(0,0,n,i,i+1,j))
      {
        help+=j;
        help--;
        fout<<help;
        break;
      }
    }
  }
  return fout<<"\n",0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair

const int maxN = 1e5 + 10;
int data[maxN][26],lazy[maxN][26],n;
//data[node][c]: jaame tedade character haye c too bazehye node
int cnt[26];

void shift(int ch, int s, int e, int id)
{
    int x = lazy[id][ch];
    if (x == -1) //chizi baraye shift dadan nadare
        return;

    int mid = s + e >> 1;

    lazy[2 * id][ch] = x;
    data[2 * id][ch] = (mid - s) * x;

    lazy[2 * id + 1][ch] = x;
    data[2 * id + 1][ch] = (e - mid) * x;

    lazy[id][ch] = -1;
}

void update(int l, int r, int ch, int val, int s = 0, int e = n, int id = 1)
{
    if (e <= l || r <= s)
        return;
    if (l <= s && e <= r)
    {
        data[id][ch] = (e - s) * val;
        lazy[id][ch] = val;
        //cout << l << " " << r << " " << data[id][ch] << " " << lazy[id][ch] << " " << char(ch + 'a') << endl;
        return;
    }

    shift(ch, s, e, id);

    int mid = s + e >> 1;
    update(l, r, ch, val, s, mid, 2 * id);
    update(l, r, ch, val, mid, e, 2 * id + 1);
    data[id][ch] = data[2 * id][ch] + data[2 * id + 1][ch];
}

int get(int l, int r, int ch, int s = 0, int e = n, int id = 1)
{
    if (e <= l || r <= s)
        return 0;
    if (l <= s && e <= r)
        return data[id][ch];
    int mid = s + e >> 1;
    shift(ch, s, e, id);
    return get(l, r, ch, s, mid, 2 * id) + get(l, r, ch, mid, e, 2 * id + 1);
}

ifstream fin ("input.txt");
ofstream fout ("output.txt");
#define cin fin
#define cout fout
int32_t main()
{
    for (int i = 0 ; i < maxN ; i++)
        for (int j = 0 ; j < 26 ; j++)
            lazy[i][j] = -1;

    string s;
    int q;
    cin >> n >> q >> s;
    for (int i = 0 ; i < n ; i++)
    {
        //cout << "Adding " << i << " " << i + 1 << " " << s[i] - 'a' << " " << 1 << endl;
        update(i, i + 1, s[i] - 'a', 1);
    }

    while (q--)
    {
        int l,r;
        cin >> l >> r;
        l--;
        int pos1 = l, pos2 = r;
        int odd = 0;
        char mid; //character ee ke fard bar omade bayad miad vasat
        for (int i = 0 ; i < 26 ; i++)
        {
            cnt[i] = get(l, r, i);
            if (cnt[i] & 1)
            {
                mid = i;
                odd++;
            }
        }

        if (odd > 1)
            continue;
        if ( (r - l) % 2 == 0 ) //toolesh zoj
            if (odd == 1) //hame bayad zoj bar omade bashan
                continue;

        for (int i = 0 ; i < 26 ; i++)
            update(l, r, i, 0); //paak kon hame ro az inja

        for (int i = 0 ; i < 26 ; i++)
        {
            int num = cnt[i] / 2;
            update(pos1, pos1 + num, i, 1); //num ta i bezar avvalesh
            update(pos2 - num, pos2, i, 1); //num ta i bezar akharesh
            pos1 += num;
            pos2 -= num;
        }

        if ((r - l) & 1)
            update(pos1, pos1 + 1, mid, 1);
    }

    for (int i = 0 ; i < n ; i++)
        for (int j = 0 ; j < 26 ; j++)
            if (get(i, i + 1, j) > 0)
                cout << (char)(j + 'a');
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxN=1e5+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 node, int st, int en, int l, int r, int ind)
{
  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(2*node+1,st,mid,l,r,ind)+get(2*node+2,mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind, int val)
{
  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(2*node+1,st,mid,l,r,ind,val);
  update(2*node+2,mid,en,l,r,ind,val);
  data[node][ind]=data[2*node+1][ind]+data[2*node+2][ind];
}
main()
{
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  fin>>n>>q>>str;
  for(int i=0;i<4 * maxN;i++)
  {
    for(int j=1;j<=26;j++)
      helper[i][j]=-1;
  }
  for(int i=0;i<n;i++)
    update(0,0,n,i,i+1,str[i]-'a'+1,1);
  while(q--)
  {
    fin>>l>>r;
    l--;
    bool odd=false,bad=false;
    for(int i=1;i<=26;i++)
    {
      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(int i=1;i<=26;i++)
        update(0,0,n,l,r,i,0);
      for(int i=1;i<=26;i++)
      {
        int wh=cnt[i] >> 1;
        update(0,0,n,l,l+wh,i,1);
        update(0,0,n,r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(0,0,n,l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=1;j<=26;j++)
    {
      char help='a';
      if(get(0,0,n,i,i+1,j))
      {
        help+=j;
        help--;
        fout<<help;
        break;
      }
    }
  }
  return fout<<"\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)/2;
  helper[2*node][ind]=helper[node][ind];
  helper[2*node+1][ind]=helper[node][ind];
  data[2*node][ind]=(mid-st)*helper[node][ind];
  data[2*node+1][ind]=(en-mid)*helper[node][ind];
  helper[node][ind]=-1;
}
int get(int node, int st, int en, int l, int r, int ind)
{
  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)/2;
  return get(2*node,st,mid,l,r,ind)+get(2*node+1,mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind, int val)
{
  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)/2;
  update(2*node,st,mid,l,r,ind,val);
  update(2*node+1,mid,en,l,r,ind,val);
  data[node][ind]=data[2*node][ind]+data[2*node+1][ind];
}
main()
{
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  #define cin fin
  #define cout fout
  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(0,0,n,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(0,0,n,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(0,0,n,l,r,i,0);
      for(int i=1;i<=26;i++)
      {
        int wh=cnt[i]/2;
        update(0,0,n,l,l+wh,i,1);
        update(0,0,n,r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(0,0,n,l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=1;j<=26;j++)
    {
      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;
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 node, int st, int en, int l, int r, int ind)
{
  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(2*node+1,st,mid,l,r,ind)+get(2*node+2,mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind, int val)
{
  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(2*node+1,st,mid,l,r,ind,val);
  update(2*node+2,mid,en,l,r,ind,val);
  data[node][ind]=data[2*node+1][ind]+data[2*node+2][ind];
}
main()
{
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  fin>>n>>q>>str;
  for(int i=0;i<4 * maxN;i++)
  {
    for(int j=0;j<26;j++)
      helper[i][j]=-1;
  }
  for(int i=0;i<n;i++)
    update(0,0,n,i,i+1,str[i]-'a',1);
  while(q--)
  {
    fin>>l>>r;
    l--;
    bool odd=false,bad=false;
    for(int i=0;i<26;i++)
    {
      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(int i=0;i<26;i++)
        update(0,0,n,l,r,i,0);
      for(int i=0;i<26;i++)
      {
        int wh=cnt[i] >> 1;
        update(0,0,n,l,l+wh,i,1);
        update(0,0,n,r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(0,0,n,l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<26;j++)
    {
      char help='a';
      if(get(0,0,n,i,i+1,j))
      {
        help+=j;
        help--;
        fout<<help;
        break;
      }
    }
  }
  return fout<<"\n",0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxN=1e5+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 node, int st, int en, int l, int r, int ind)
{
  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(2*node+1,st,mid,l,r,ind)+get(2*node+2,mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind, int val)
{
  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(2*node+1,st,mid,l,r,ind,val);
  update(2*node+2,mid,en,l,r,ind,val);
  data[node][ind]=data[2*node+1][ind]+data[2*node+2][ind];
}
main()
{
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  fin>>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(0,0,n,i,i+1,str[i]-'a'+1,1);
  while(q--)
  {
    fin>>l>>r;
    l--;
    bool odd=false,bad=false;
    for(int i=1;i<=26;i++)
    {
      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(int i=1;i<=26;i++)
        update(0,0,n,l,r,i,0);
      for(int i=1;i<=26;i++)
      {
        int wh=cnt[i] >> 1;
        update(0,0,n,l,l+wh,i,1);
        update(0,0,n,r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(0,0,n,l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=1;j<=26;j++)
    {
      char help='a';
      if(get(0,0,n,i,i+1,j))
      {
        help+=j;
        help--;
        fout<<help;
        break;
      }
    }
  }
  return fout<<"\n",0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxN=1e5+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 node, int st, int en, int l, int r, int ind)
{
  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(2*node+1,st,mid,l,r,ind)+get(2*node+2,mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind, int val)
{
  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(2*node+1,st,mid,l,r,ind,val);
  update(2*node+2,mid,en,l,r,ind,val);
  data[node][ind]=data[2*node+1][ind]+data[2*node+2][ind];
}
main()
{
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  fin>>n>>q>>str;
  for(int i=0;i<4 * maxN;i++)
  {
    for(int j=0;j<26;j++)
      helper[i][j]=-1;
  }
  for(int i=0;i<n;i++)
    update(0,0,n,i,i+1,str[i]-'a'+1,1);
  while(q--)
  {
    fin>>l>>r;
    l--;
    bool odd=false,bad=false;
    for(int i=0;i<26;i++)
    {
      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(int i=0;i<26;i++)
        update(0,0,n,l,r,i,0);
      for(int i=0;i<26;i++)
      {
        int wh=cnt[i] >> 1;
        update(0,0,n,l,l+wh,i,1);
        update(0,0,n,r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(0,0,n,l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<26;j++)
    {
      char help='a';
      if(get(0,0,n,i,i+1,j))
      {
        help+=j;
        help--;
        fout<<help;
        break;
      }
    }
  }
  return fout<<"\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)/2;
  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 node, int st, int en, int l, int r, int ind)
{
  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)/2;
  return get(2*node+1,st,mid,l,r,ind)+get(2*node+2,mid,en,l,r,ind);
}
void update(int node, int st, int en, int l, int r, int ind, int val)
{
  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)/2;
  update(2*node+1,st,mid,l,r,ind,val);
  update(2*node+2,mid,en,l,r,ind,val);
  data[node][ind]=data[2*node+1][ind]+data[2*node+2][ind];
}
main()
{
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  fin>>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(0,0,n,i,i+1,str[i]-'a'+1,1);
  while(q--)
  {
    fin>>l>>r;
    l--;
    bool odd=false,bad=false;
    for(int i=1;i<=26;i++)
    {
      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(int i=1;i<=26;i++)
        update(0,0,n,l,r,i,0);
      for(int i=1;i<=26;i++)
      {
        int wh=cnt[i]/2;
        update(0,0,n,l,l+wh,i,1);
        update(0,0,n,r-wh,r,i,1);
        r-=wh;
        l+=wh;
      }
      if(odd)
        update(0,0,n,l,l+1,help,1);
    }
  }
  for(int i=0;i<n;i++)
  {
    for(int j=1;j<=26;j++)
    {
      char help='a';
      if(get(0,0,n,i,i+1,j))
      {
        help+=j;
        help--;
        fout<<help;
        break;
      }
    }
  }
  return fout<<"\n",0;
}


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

#define lrt rt<<1
#define rrt rt<<1|1
#define lson l,m,lrt
#define rson m+1,r,rrt

const int N = 100100;
int n, m;
string s;

struct Node{
    int num[26];
    void init() {
        memset(num, 0, sizeof num);
    }
    Node operator + (const Node& b) const  {
        Node res;
        for(int i = 0; i < 26; i++) res.num[i] = num[i]+b.num[i];
        return res;
    }
};
struct Node2{
    char ch;
    int num;
    Node2() {}
    Node2(char ch, int num) : ch(ch), num(num) {}
};

struct Seg{
    Node node;
    vector<Node2> ve;
    int flag;
}seg[N<<4];

void push_up(int rt) {
    seg[rt].node = seg[lrt].node+seg[rrt].node;
}
void build(int l, int r, int rt) {
    seg[rt].node.init();
    seg[rt].flag = 0;
    seg[rt].ve.clear();
    if(l == r) {
        int x = s[l]-'a';
        seg[rt].node.num[x] = 1;
        return ;
    }
    int m = (l+r)>>1;
    build(lson); build(rson);
    push_up(rt);
}
void maintain(int rt) {
    seg[rt].node.init();
    for(int i = 0; i < seg[rt].ve.size(); i++) {
        int x = seg[rt].ve[i].ch-'a';
        seg[rt].node.num[x] += seg[rt].ve[i].num;
    }
}
void push_down(int l, int r, int rt) {
    int m = (l+r)>>1;
    if(seg[rt].flag) {
        seg[lrt].ve.clear();
        seg[rrt].ve.clear();
        int cnt = 0;
        for(int i = 0; i < seg[rt].ve.size(); i++) {
            if(seg[rt].ve[i].num+cnt <= (m-l+1)) {
                seg[lrt].ve.push_back(seg[rt].ve[i]);
                cnt += seg[rt].ve[i].num;
            } else if(cnt < (m-l+1)) {
                seg[lrt].ve.push_back(Node2(seg[rt].ve[i].ch, m-l+1-cnt));
                cnt = m-l+1;
                seg[rrt].ve.push_back(Node2(seg[rt].ve[i].ch, seg[rt].ve[i].num-(m-l+1-cnt)));
            } else {
                seg[rrt].ve.push_back(seg[rt].ve[i]);
            }
        }
        seg[lrt].flag = seg[rrt].flag = 1;
        maintain(lrt); maintain(rrt);

        seg[rt].flag = 0;
        seg[rt].ve.clear();
    }
}
vector<Node2> v, tmp;
void update(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        tmp.clear();
        int cnt = 0;
        for(int i = 0; i < v.size(); i++) {
            if(cnt+v[i].num <= l-L) cnt += v[i].num;
            else if(cnt == l-L) tmp.push_back(v[i]);
            else {
                tmp.push_back( Node2( v[i].ch, v[i].num-(l-L-cnt) ) );
                cnt = l-L;
            }
        }

        seg[rt].ve.clear();
        cnt = 0;
        for(int i = 0; i < tmp.size(); i++) {
            if(cnt == r-l+1) break;
            if(cnt+tmp[i].num <= r-l+1) {
                seg[rt].ve.push_back(tmp[i]);
                cnt += tmp[i].num;
            } else {
                seg[rt].ve.push_back(Node2(tmp[i].ch, r-l+1-cnt));
                cnt = r-l+1;
            }
        }

        seg[rt].flag = 1;
        maintain(rt);
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(L <= m) update(L, R, lson);
    if(R > m) update(L, R, rson);
    push_up(rt);
}
Node res;
void query(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        res = res+seg[rt].node;
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(R <= m) query(L, R, lson);
    else if(L > m) query(L, R, rson);
    else { query(L, m, lson); query(m+1, R, rson); }
}

string ss;
void query2(int l, int r, int rt) {
    if(l == r) {
        for(int i = 0; i < 26; i++) {
            if(seg[rt].node.num[i]) {
                ss += (char)('a'+i);
            }
        }
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    query2(lson); query2(rson);
}

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

    cin>>n>>m;
    cin>>s;
    int len = s.length();
    build(0, len-1, 1);
    while(m--) {
        int l, r;
        cin>>l>>r;
        if(n == 500) cout<<l<<' '<<r<<endl;
        res.init();
        query(l-1, r-1, 0, len-1, 1);

        int cnt = 0;
        int sum = 0;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt++;
            sum += res.num[i];
        }
        if(cnt > 1) continue;

        v.clear();
        cnt = -1;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt = i;
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }
        if(cnt != -1) v.push_back(Node2('a'+cnt, 1));
        for(int i = 25; i >= 0; i--) {
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }

        update(l-1, r-1, 0, len-1, 1);
    }

    ss = "";
    query2(0, len-1, 1);
    cout<<ss<<endl;

    return 0;
}


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

#define lrt rt<<1
#define rrt rt<<1|1
#define lson l,m,lrt
#define rson m+1,r,rrt

const int N = 100100;
int n, m;
string s;

struct Node{
    int num[26];
    void init() {
        memset(num, 0, sizeof num);
    }
    Node operator + (const Node& b) const  {
        Node res;
        for(int i = 0; i < 26; i++) res.num[i] = num[i]+b.num[i];
        return res;
    }
};
struct Node2{
    char ch;
    int num;
    Node2() {}
    Node2(char ch, int num) : ch(ch), num(num) {}
};

struct Seg{
    Node node;
    vector<Node2> ve;
    int flag;
}seg[N<<4];

void push_up(int rt) {
    seg[rt].node = seg[lrt].node+seg[rrt].node;
}
void build(int l, int r, int rt) {
    seg[rt].node.init();
    seg[rt].flag = 0;
    seg[rt].ve.clear();
    if(l == r) {
        int x = s[l]-'a';
        seg[rt].node.num[x] = 1;
        return ;
    }
    int m = (l+r)>>1;
    build(lson); build(rson);
    push_up(rt);
}
void maintain(int rt) {
    seg[rt].node.init();
    for(int i = 0; i < seg[rt].ve.size(); i++) {
        int x = seg[rt].ve[i].ch-'a';
        seg[rt].node.num[x] += seg[rt].ve[i].num;
    }
}
void push_down(int l, int r, int rt) {
    int m = (l+r)>>1;
    if(seg[rt].flag) {
        seg[lrt].ve.clear();
        seg[rrt].ve.clear();
        int cnt = 0;
        for(int i = 0; i < seg[rt].ve.size(); i++) {
            if(seg[rt].ve[i].num+cnt <= (m-l+1)) {
                seg[lrt].ve.push_back(seg[rt].ve[i]);
                cnt += seg[rt].ve[i].num;
            } else if(cnt < (m-l+1)) {
                seg[lrt].ve.push_back(Node2(seg[rt].ve[i].ch, m-l+1-cnt));
                cnt = m-l+1;
                seg[rrt].ve.push_back(Node2(seg[rt].ve[i].ch, seg[rt].ve[i].num-(m-l+1-cnt)));
            } else {
                seg[rrt].ve.push_back(seg[rt].ve[i]);
            }
        }
        seg[lrt].flag = seg[rrt].flag = 1;
        maintain(lrt); maintain(rrt);

        seg[rt].flag = 0;
        seg[rt].ve.clear();
    }
}
vector<Node2> v, tmp;
void update(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        tmp.clear();
        int cnt = 0;
        for(int i = 0; i < v.size(); i++) {
            if(cnt+v[i].num <= l-L) cnt += v[i].num;
            else if(cnt == l-L) tmp.push_back(v[i]);
            else {
                tmp.push_back( Node2( v[i].ch, v[i].num-(l-L-cnt) ) );
                cnt = l-L;
            }
        }

        seg[rt].ve.clear();
        cnt = 0;
        for(int i = 0; i < tmp.size(); i++) {
            if(cnt == r-l+1) break;
            if(cnt+tmp[i].num <= r-l+1) {
                seg[rt].ve.push_back(tmp[i]);
                cnt += tmp[i].num;
            } else {
                seg[rt].ve.push_back(Node2(tmp[i].ch, r-l+1-cnt));
                cnt = r-l+1;
            }
        }

        seg[rt].flag = 1;
        maintain(rt);
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(L <= m) update(L, R, lson);
    if(R > m) update(L, R, rson);
    push_up(rt);
}
Node res;
void query(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        res = res+seg[rt].node;
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(R <= m) query(L, R, lson);
    else if(L > m) query(L, R, rson);
    else { query(L, m, lson); query(m+1, R, rson); }
}

string ss;
void query2(int l, int r, int rt) {
    if(l == r) {
        for(int i = 0; i < 26; i++) {
            if(seg[rt].node.num[i]) {
                ss += (char)('a'+i);
            }
        }
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    query2(lson); query2(rson);
}

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

    cin>>n>>m;
    cin>>s;
    int len = s.length();
    build(0, len-1, 1);
    while(m--) {
        int l, r;
        cin>>l>>r;
        cout<<l<<r<<endl;
        res.init();
        query(l-1, r-1, 0, len-1, 1);

        int cnt = 0;
        int sum = 0;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt++;
            sum += res.num[i];
        }
        if(cnt > 1) continue;

        v.clear();
        cnt = -1;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt = i;
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }
        if(cnt != -1) v.push_back(Node2('a'+cnt, 1));
        for(int i = 25; i >= 0; i--) {
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }

        update(l-1, r-1, 0, len-1, 1);
    }

    ss = "";
    query2(0, len-1, 1);
    cout<<ss<<endl;

    return 0;
}


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

#define lrt rt<<1
#define rrt rt<<1|1
#define lson l,m,lrt
#define rson m+1,r,rrt

const int N = 100100;
int n, m;
string s;

struct Node{
    int num[26];
    void init() {
        memset(num, 0, sizeof num);
    }
    Node operator + (const Node& b) const  {
        Node res;
        for(int i = 0; i < 26; i++) res.num[i] = num[i]+b.num[i];
        return res;
    }
};
struct Node2{
    char ch;
    int num;
    Node2() {}
    Node2(char ch, int num) : ch(ch), num(num) {}
};

struct Seg{
    Node node;
    vector<Node2> ve;
    int flag;
}seg[N<<4];

void push_up(int rt) {
    seg[rt].node = seg[lrt].node+seg[rrt].node;
}
void build(int l, int r, int rt) {
    seg[rt].node.init();
    seg[rt].flag = 0;
    seg[rt].ve.clear();
    if(l == r) {
        int x = s[l]-'a';
        seg[rt].node.num[x] = 1;
        return ;
    }
    int m = (l+r)>>1;
    build(lson); build(rson);
    push_up(rt);
}
void maintain(int rt) {
    seg[rt].node.init();
    for(int i = 0; i < seg[rt].ve.size(); i++) {
        int x = seg[rt].ve[i].ch-'a';
        seg[rt].node.num[x] += seg[rt].ve[i].num;
    }
}
void push_down(int l, int r, int rt) {
    int m = (l+r)>>1;
    if(seg[rt].flag) {
        seg[lrt].ve.clear();
        seg[rrt].ve.clear();
        int cnt = 0;
        for(int i = 0; i < seg[rt].ve.size(); i++) {
            if(seg[rt].ve[i].num+cnt <= (m-l+1)) {
                seg[lrt].ve.push_back(seg[rt].ve[i]);
                cnt += seg[rt].ve[i].num;
            } else if(cnt < (m-l+1)) {
                seg[lrt].ve.push_back(Node2(seg[rt].ve[i].ch, m-l+1-cnt));
                seg[rrt].ve.push_back(Node2(seg[rt].ve[i].ch, seg[rt].ve[i].num-(m-l+1-cnt)));
                cnt = m-l+1;
            } else {
                seg[rrt].ve.push_back(seg[rt].ve[i]);
            }
        }
        seg[lrt].flag = seg[rrt].flag = 1;
        maintain(lrt); maintain(rrt);

        seg[rt].flag = 0;
        seg[rt].ve.clear();
    }
}
vector<Node2> v, tmp;
void update(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        tmp.clear();
        int cnt = 0;
        for(int i = 0; i < v.size(); i++) {
            if(cnt+v[i].num <= l-L) cnt += v[i].num;
            else if(cnt == l-L) tmp.push_back(v[i]);
            else {
                tmp.push_back( Node2( v[i].ch, v[i].num-(l-L-cnt) ) );
                cnt = l-L;
            }
        }

        seg[rt].ve.clear();
        cnt = 0;
        for(int i = 0; i < tmp.size(); i++) {
            if(cnt == r-l+1) break;
            if(cnt+tmp[i].num <= r-l+1) {
                seg[rt].ve.push_back(tmp[i]);
                cnt += tmp[i].num;
            } else {
                seg[rt].ve.push_back(Node2(tmp[i].ch, r-l+1-cnt));
                cnt = r-l+1;
            }
        }

        seg[rt].flag = 1;
        maintain(rt);
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(L <= m) update(L, R, lson);
    if(R > m) update(L, R, rson);
    push_up(rt);
}
Node res;
void query(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        res = res+seg[rt].node;
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(R <= m) query(L, R, lson);
    else if(L > m) query(L, R, rson);
    else { query(L, m, lson); query(m+1, R, rson); }
    push_up(rt);
}

string ss;
void query2(int l, int r, int rt) {

//    cout<<l<<' '<<r<<endl;
//    for(int i = 0; i <seg[rt].ve.size(); i++) cout<<seg[rt].ve[i].ch<<' '<<seg[rt].ve[i].num<<endl;
//    cout<<endl;

    if(l == r) {
        for(int i = 0; i < 26; i++) {
            if(seg[rt].node.num[i]) {
                ss += (char)('a'+i);
            }
        }
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    query2(lson); query2(rson);
}

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

    cin>>n>>m;
    cin>>s;
    int len = s.length();
    build(0, len-1, 1);
    while(m--) {
        int l, r;
        cin>>l>>r;
        res.init();
        query(l-1, r-1, 0, len-1, 1);

        int cnt = 0;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt++;
        }
        if(cnt > 1) continue;

        v.clear();
        cnt = -1;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt = i;
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }
        if(cnt != -1) v.push_back(Node2('a'+cnt, 1));
        for(int i = 25; i >= 0; i--) {
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }

        //for(int i = 0; i < v.size(); i++) cout<<v[i].ch<<' '<<v[i].num<<endl;

        update(l-1, r-1, 0, len-1, 1);

//        ss = "";
//        query2(0, len-1, 1);
//        cout<<ss<<endl;
    }

    ss = "";
    query2(0, len-1, 1);
    cout<<ss<<endl;

    return 0;
}


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

#define lrt rt<<1
#define rrt rt<<1|1
#define lson l,m,lrt
#define rson m+1,r,rrt

const int N = 100100;
int n, m;
string s;

struct Node{
    int num[26];
    void init() {
        memset(num, 0, sizeof num);
    }
    Node operator + (const Node& b) const  {
        Node res;
        for(int i = 0; i < 26; i++) res.num[i] = num[i]+b.num[i];
        return res;
    }
};
struct Node2{
    char ch;
    int num;
    Node2() {}
    Node2(char ch, int num) : ch(ch), num(num) {}
};

struct Seg{
    Node node;
    vector<Node2> ve;
    int flag;
}seg[N<<4];

void push_up(int rt) {
    seg[rt].node = seg[lrt].node+seg[rrt].node;
}
void build(int l, int r, int rt) {
    seg[rt].node.init();
    seg[rt].flag = 0;
    seg[rt].ve.clear();
    if(l == r) {
        int x = s[l]-'a';
        seg[rt].node.num[x] = 1;
        return ;
    }
    int m = (l+r)>>1;
    build(lson); build(rson);
    push_up(rt);
}
void maintain(int rt) {
    seg[rt].node.init();
    for(int i = 0; i < seg[rt].ve.size(); i++) {
        int x = seg[rt].ve[i].ch-'a';
        seg[rt].node.num[x] += seg[rt].ve[i].num;
    }
}
void push_down(int l, int r, int rt) {
    int m = (l+r)>>1;
    if(seg[rt].flag) {
        seg[lrt].ve.clear();
        seg[rrt].ve.clear();
        int cnt = 0;
        for(int i = 0; i < seg[rt].ve.size(); i++) {
            if(seg[rt].ve[i].num+cnt <= (m-l+1)) {
                seg[lrt].ve.push_back(seg[rt].ve[i]);
                cnt += seg[rt].ve[i].num;
            } else if(cnt < (m-l+1)) {
                seg[lrt].ve.push_back(Node2(seg[rt].ve[i].ch, m-l+1-cnt));
                cnt = m-l+1;
                seg[rrt].ve.push_back(Node2(seg[rt].ve[i].ch, seg[rt].ve[i].num-(m-l+1-cnt)));
            } else {
                seg[rrt].ve.push_back(seg[rt].ve[i]);
            }
        }
        seg[lrt].flag = seg[rrt].flag = 1;
        maintain(lrt); maintain(rrt);

        seg[rt].flag = 0;
        seg[rt].ve.clear();
    }
}
vector<Node2> v, tmp;
void update(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        tmp.clear();
        int cnt = 0;
        for(int i = 0; i < v.size(); i++) {
            if(cnt+v[i].num <= l-L) cnt += v[i].num;
            else if(cnt == l-L) tmp.push_back(v[i]);
            else {
                tmp.push_back( Node2( v[i].ch, v[i].num-(l-L-cnt) ) );
                cnt = l-L;
            }
        }

        seg[rt].ve.clear();
        cnt = 0;
        for(int i = 0; i < tmp.size(); i++) {
            if(cnt == r-l+1) break;
            if(cnt+tmp[i].num <= r-l+1) {
                seg[rt].ve.push_back(tmp[i]);
                cnt += tmp[i].num;
            } else {
                seg[rt].ve.push_back(Node2(tmp[i].ch, r-l+1-cnt));
                cnt = r-l+1;
            }
        }

        seg[rt].flag = 1;
        maintain(rt);
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(L <= m) update(L, R, lson);
    if(R > m) update(L, R, rson);
    push_up(rt);
}
Node res;
void query(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        res = res+seg[rt].node;
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(R <= m) query(L, R, lson);
    else if(L > m) query(L, R, rson);
    else { query(L, m, lson); query(m+1, R, rson); }
}

string ss;
void query2(int l, int r, int rt) {
    if(l == r) {
        for(int i = 0; i < 26; i++) {
            if(seg[rt].node.num[i]) {
                ss += (char)('a'+i);
            }
        }
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    query2(lson); query2(rson);
}

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

    cin>>n>>m;
    cin>>s;
    int len = s.length();
    build(0, len-1, 1);
    while(m--) {
        int l, r;
        cin>>l>>r;
        res.init();
        query(l-1, r-1, 0, len-1, 1);

        int cnt = 0;
        int sum = 0;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt++;
            sum += res.num[i];
        }
        if(sum != r-l+1) {
            cout<<"debug"<<endl;
            return 0;
        }
        if(cnt > 1) continue;

        v.clear();
        cnt = -1;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt = i;
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }
        if(cnt != -1) v.push_back(Node2('a'+cnt, 1));
        for(int i = 25; i >= 0; i--) {
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }

        update(l-1, r-1, 0, len-1, 1);
    }

    ss = "";
    query2(0, len-1, 1);
    cout<<ss<<endl;

    return 0;
}


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

#define lrt rt<<1
#define rrt rt<<1|1
#define lson l,m,lrt
#define rson m+1,r,rrt

const int N = 100100;
int n, m;
string s;

struct Node{
    int num[26];
    void init() {
        memset(num, 0, sizeof num);
    }
    Node operator + (const Node& b) const  {
        Node res;
        for(int i = 0; i < 26; i++) res.num[i] = num[i]+b.num[i];
        return res;
    }
};
struct Node2{
    char ch;
    int num;
    Node2() {}
    Node2(char ch, int num) : ch(ch), num(num) {}
};

struct Seg{
    Node node;
    vector<Node2> ve;
    int flag;
}seg[N<<4];

void push_up(int rt) {
    seg[rt].node = seg[lrt].node+seg[rrt].node;
}
void build(int l, int r, int rt) {
    seg[rt].node.init();
    seg[rt].flag = 0;
    seg[rt].ve.clear();
    if(l == r) {
        int x = s[l]-'a';
        seg[rt].node.num[x] = 1;
        return ;
    }
    int m = (l+r)>>1;
    build(lson); build(rson);
    push_up(rt);
}
void maintain(int rt) {
    seg[rt].node.init();
    for(int i = 0; i < seg[rt].ve.size(); i++) {
        int x = seg[rt].ve[i].ch-'a';
        seg[rt].node.num[x] += seg[rt].ve[i].num;
    }
}
void push_down(int l, int r, int rt) {
    int m = (l+r)>>1;
    if(seg[rt].flag) {
        seg[lrt].ve.clear();
        seg[rrt].ve.clear();
        int cnt = 0;
        for(int i = 0; i < seg[rt].ve.size(); i++) {
            if(seg[rt].ve[i].num+cnt <= (m-l+1)) {
                seg[lrt].ve.push_back(seg[rt].ve[i]);
                cnt += seg[rt].ve[i].num;
            } else if(cnt < (m-l+1)) {
                seg[lrt].ve.push_back(Node2(seg[rt].ve[i].ch, m-l+1-cnt));
                cnt = m-l+1;
                seg[rrt].ve.push_back(Node2(seg[rt].ve[i].ch, seg[rt].ve[i].num-(m-l+1-cnt)));
            } else {
                seg[rrt].ve.push_back(seg[rt].ve[i]);
            }
        }
        seg[lrt].flag = seg[rrt].flag = 1;
        maintain(lrt); maintain(rrt);

        seg[rt].flag = 0;
        seg[rt].ve.clear();
    }
}
vector<Node2> v, tmp;
void update(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        tmp.clear();
        int cnt = 0;
        for(int i = 0; i < v.size(); i++) {
            if(cnt+v[i].num <= l-L) cnt += v[i].num;
            else if(cnt == l-L) tmp.push_back(v[i]);
            else {
                tmp.push_back( Node2( v[i].ch, v[i].num-(l-L-cnt) ) );
                cnt = l-L;
            }
        }

        seg[rt].ve.clear();
        cnt = 0;
        for(int i = 0; i < tmp.size(); i++) {
            if(cnt == r-l+1) break;
            if(cnt+tmp[i].num <= r-l+1) {
                seg[rt].ve.push_back(tmp[i]);
                cnt += tmp[i].num;
            } else {
                seg[rt].ve.push_back(Node2(tmp[i].ch, r-l+1-cnt));
                cnt = r-l+1;
            }
        }

        seg[rt].flag = 1;
        maintain(rt);
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(L <= m) update(L, R, lson);
    if(R > m) update(L, R, rson);
    push_up(rt);
}
Node res;
void query(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        res = res+seg[rt].node;
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(R <= m) query(L, R, lson);
    else if(L > m) query(L, R, rson);
    else { query(L, m, lson); query(m+1, R, rson); }
}

string ss;
void query2(int l, int r, int rt) {
    if(l == r) {
        for(int i = 0; i < 26; i++) {
            if(seg[rt].node.num[i]) {
                ss += (char)('a'+i);
            }
        }
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    query2(lson); query2(rson);
}

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

    cin>>n>>m;
    cin>>s;
    int len = s.length();
    build(0, len-1, 1);
    while(m--) {
        int l, r;
        cin>>l>>r;
        if(n == 500) cout<<l<<r<<endl;
        res.init();
        query(l-1, r-1, 0, len-1, 1);

        int cnt = 0;
        int sum = 0;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt++;
            sum += res.num[i];
        }
        if(cnt > 1) continue;

        v.clear();
        cnt = -1;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt = i;
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }
        if(cnt != -1) v.push_back(Node2('a'+cnt, 1));
        for(int i = 25; i >= 0; i--) {
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }

        update(l-1, r-1, 0, len-1, 1);
    }

    ss = "";
    query2(0, len-1, 1);
    cout<<ss<<endl;

    return 0;
}


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

#define lrt rt<<1
#define rrt rt<<1|1
#define lson l,m,lrt
#define rson m+1,r,rrt

const int N = 100100;
int n, m;
string s;

struct Node{
    int num[26];
    void init() {
        memset(num, 0, sizeof num);
    }
    Node operator + (const Node& b) const  {
        Node res;
        for(int i = 0; i < 26; i++) res.num[i] = num[i]+b.num[i];
        return res;
    }
};
struct Node2{
    char ch;
    int num;
    Node2() {}
    Node2(char ch, int num) : ch(ch), num(num) {}
};

struct Seg{
    Node node;
    vector<Node2> ve;
    int flag;
}seg[N<<4];

void push_up(int rt) {
    seg[rt].node = seg[lrt].node+seg[rrt].node;
}
void build(int l, int r, int rt) {
    seg[rt].node.init();
    seg[rt].flag = 0;
    seg[rt].ve.clear();
    if(l == r) {
        int x = s[l]-'a';
        seg[rt].node.num[x] = 1;
        return ;
    }
    int m = (l+r)>>1;
    build(lson); build(rson);
    push_up(rt);
}
void maintain(int rt) {
    seg[rt].node.init();
    for(int i = 0; i < seg[rt].ve.size(); i++) {
        int x = seg[rt].ve[i].ch-'a';
        seg[rt].node.num[x] += seg[rt].ve[i].num;
    }
}
void push_down(int l, int r, int rt) {
    int m = (l+r)>>1;
    if(seg[rt].flag) {
        seg[lrt].ve.clear();
        seg[rrt].ve.clear();
        int cnt = 0;
        for(int i = 0; i < seg[rt].ve.size(); i++) {
            if(seg[rt].ve[i].num+cnt <= (m-l+1)) {
                seg[lrt].ve.push_back(Node2(seg[rt].ve[i].ch, seg[rt].ve[i].num));
                cnt += seg[rt].ve[i].num;
            } else if(cnt < (m-l+1)) {
                seg[lrt].ve.push_back(Node2(seg[rt].ve[i].ch, m-l+1-cnt));
                cnt = m-l+1;
                seg[rrt].ve.push_back(Node2(seg[rt].ve[i].ch, seg[rt].ve[i].num-(m-l+1-cnt)));
            } else {
                seg[rrt].ve.push_back(Node2(seg[rt].ve[i].ch, seg[rt].ve[i].num));
            }
        }
        seg[lrt].flag = seg[rrt].flag = 1;
        maintain(lrt); maintain(rrt);

        seg[rt].flag = 0;
        seg[rt].ve.clear();
    }
}
vector<Node2> v, tmp;
void update(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        tmp.clear();
        int cnt = 0;
        for(int i = 0; i < v.size(); i++) {
            if(cnt+v[i].num <= l-L) cnt += v[i].num;
            else if(cnt == l-L) tmp.push_back(v[i]);
            else {
                tmp.push_back( Node2( v[i].ch, v[i].num-(l-L-cnt) ) );
                cnt = l-L;
            }
        }

        seg[rt].ve.clear();
        cnt = 0;
        for(int i = 0; i < tmp.size(); i++) {
            if(cnt == r-l+1) break;
            if(cnt+tmp[i].num <= r-l+1) {
                seg[rt].ve.push_back(tmp[i]);
                cnt += tmp[i].num;
            } else {
                seg[rt].ve.push_back(Node2(tmp[i].ch, r-l+1-cnt));
                cnt = r-l+1;
            }
        }

        seg[rt].flag = 1;
        maintain(rt);
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(L <= m) update(L, R, lson);
    if(R > m) update(L, R, rson);
    push_up(rt);
}
Node res;
void query(int L, int R, int l, int r, int rt) {
    if(L<=l && r<=R) {
        res = res+seg[rt].node;
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    if(R <= m) query(L, R, lson);
    else if(L > m) query(L, R, rson);
    else { query(L, m, lson); query(m+1, R, rson); }
}

string ss;
void query2(int l, int r, int rt) {
    if(l == r) {
        for(int i = 0; i < 26; i++) {
            if(seg[rt].node.num[i]) {
                ss += (char)('a'+i);
            }
        }
        return ;
    }
    push_down(l, r, rt);
    int m = (l+r)>>1;
    query2(lson); query2(rson);
}

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

    cin>>n>>m;
    cin>>s;
    int len = s.length();
    build(0, len-1, 1);
    while(m--) {
        int l, r;
        cin>>l>>r;
        res.init();
        query(l-1, r-1, 0, len-1, 1);

        int cnt = 0;
        for(int i = 0; i < 26; i++)
            if(res.num[i]&1) cnt++;
        if(cnt > 1) continue;

//        for(int i = 0; i < 26; i++) {
//            if(res.num[i] == 0) continue;
//            cout<<(char)('a'+i)<<' '<<res.num[i]<<endl;
//        }

        v.clear();
        cnt = -1;
        for(int i = 0; i < 26; i++) {
            if(res.num[i]&1) cnt = i;
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }
        if(cnt != -1) v.push_back(Node2('a'+cnt, 1));
        for(int i = 25; i >= 0; i--) {
            if(res.num[i] <= 1) continue;
            v.push_back(Node2('a'+i, res.num[i]/2));
        }

//        for(int i = 0; i < v.size(); i++) {
//            cout<<v[i].ch<<' '<<v[i].num<<endl;
//        }

        update(l-1, r-1, 0, len-1, 1);

    }

    ss = "";
    query2(0, len-1, 1);
    cout<<ss<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define N 400009
#define BLOCK 350
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld r,j,l,x,y,m,n,s,q,i,z,p,k,t,w,sz;string s1,s2;
lld tree[N][27],cnt[27],lazy[N][27];
lld build(lld node,lld l,lld r,lld pos)
{
  lazy[node][pos]=-1;
  if(l==r)
  {
    tree[node][pos]=(s1[l]-'a'==pos)?1:0;
    return 0;
  }
  lld mid=(l+r)/2;
  build(2*node,l,mid,pos),build(2*node+1,mid+1,r,pos);
  tree[node][pos]=tree[2*node][pos]+tree[2*node+1][pos];
}
lld query(lld node,lld l,lld r,lld left,lld right,lld pos)
{
  if(lazy[node][pos]!=-1)
  {
    tree[node][pos]=(r-l+1)*lazy[node][pos];
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
    }
    lazy[node][pos]=-1;
  }
  if(left>r||l>right)return 0;
  if(left<=l&&right>=r)
  {
    return tree[node][pos];
  }
  lld mid=(l+r)/2;
  return query(2*node,l,mid,left,right,pos)+query(2*node+1,mid+1,r,left,right,pos);
}
lld update(lld node,lld l,lld r,lld left,lld right,lld val,lld pos)
{
  if(lazy[node][pos]!=-1)
  {
    tree[node][pos]=(r-l+1)*lazy[node][pos];
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
    }
    lazy[node][pos]=-1;
  }
  if(left>r||l>right)return 0;
  if(left<=l&&right>=r)
  {
    tree[node][pos]=(r-l+1)*val;
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=val;
    }
    return 0;
  }
  lld mid=(l+r)/2;
  update(2*node,l,mid,left,right,val,pos),update(2*node+1,mid+1,r,left,right,val,pos);
  tree[node][pos]=tree[2*node][pos]+tree[2*node+1][pos];
}
lld ans(lld node,lld l,lld r)
{
  for(lld pos=0;pos<26;pos++)
  {
    if(lazy[node][pos]!=-1)
    {
      tree[node][pos]=(r-l+1)*lazy[node][pos];
      if(l!=r)
      {
        lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
      }
      lazy[node][pos]=-1;
    }
  }
  if(l==r)
  {
    rep(i,0,26)if(tree[node][i])cout<<(char)('a'+i);
    return 0;
  }
  lld mid=(l+r)/2;
  ans(2*node,l,mid),ans(2*node+1,mid+1,r);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  cin>>n>>q>>s1;
  s1=" "+s1;
  rep(i,0,26)build(1,1,n,i);
  while(q--)
  {
    cin>>x>>y;
    rep(i,0,26)cnt[i]=query(1,1,n,x,y,i);
    k=0;
    rep(i,0,26)
    {
      if(cnt[i]%2)l=i,k++;
    }
    if(k>=2)continue;
    if(k==1)cnt[l]--;
    rep(i,0,26)update(1,1,n,x,y,0,i);
    if(k==0)
    {
      lld curr=x;
      rep(i,0,26)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
      for(i=25;i>=0;i--)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
    }
    else
    {
      lld curr=x;
      rep(i,0,26)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
      update(1,1,n,curr,curr,1,l);
      curr++;
      for(i=25;i>=0;i--)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
    }
  }
  ans(1,1,n);
}


#include <bits/stdc++.h>
using namespace std;
typedef int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define N 400009
#define BLOCK 350
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld r,j,l,x,y,m,n,s,q,i,z,p,k,t,w,sz;string s1,s2;
lld tree[N][27],cnt[27],lazy[N][27];
lld build(lld node,lld l,lld r,lld pos)
{
  lazy[node][pos]=-1;
  if(l==r)
  {
    tree[node][pos]=(s1[l]-'a'==pos)?1:0;
    return 0;
  }
  lld mid=(l+r)/2;
  build(2*node,l,mid,pos),build(2*node+1,mid+1,r,pos);
  tree[node][pos]=tree[2*node][pos]+tree[2*node+1][pos];
}
lld query(lld node,lld l,lld r,lld left,lld right,lld pos)
{
  if(lazy[node][pos]!=-1)
  {
    tree[node][pos]=(r-l+1)*lazy[node][pos];
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
    }
    lazy[node][pos]=-1;
  }
  if(left>r||l>right)return 0;
  if(left<=l&&right>=r)
  {
    return tree[node][pos];
  }
  lld mid=(l+r)/2;
  return query(2*node,l,mid,left,right,pos)+query(2*node+1,mid+1,r,left,right,pos);
}
lld update(lld node,lld l,lld r,lld left,lld right,lld val,lld pos)
{
  if(lazy[node][pos]!=-1)
  {
    tree[node][pos]=(r-l+1)*lazy[node][pos];
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
    }
    lazy[node][pos]=-1;
  }
  if(left>r||l>right)return 0;
  if(left<=l&&right>=r)
  {
    tree[node][pos]=(r-l+1)*val;
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=val;
    }
    return 0;
  }
  lld mid=(l+r)/2;
  update(2*node,l,mid,left,right,val,pos),update(2*node+1,mid+1,r,left,right,val,pos);
  tree[node][pos]=tree[2*node][pos]+tree[2*node+1][pos];
}
lld ans(lld node,lld l,lld r)
{
  for(lld pos=0;pos<26;pos++)
  {
    if(lazy[node][pos]!=-1)
    {
      tree[node][pos]=(r-l+1)*lazy[node][pos];
      if(l!=r)
      {
        lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
      }
      lazy[node][pos]=-1;
    }
  }
  if(l==r)
  {
    rep(i,0,26)if(tree[node][i])cout<<(char)('a'+i);
    return 0;
  }
  lld mid=(l+r)/2;
  ans(2*node,l,mid),ans(2*node+1,mid+1,r);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  cin>>n>>q>>s1;
  s1=" "+s1;
  rep(i,0,26)build(1,1,n,i);
  while(q--)
  {
    cin>>x>>y;
    rep(i,0,26)cnt[i]=query(1,1,n,x,y,i);
    k=0;
    rep(i,0,26)
    {
      if(cnt[i]%2)l=i,k++;
    }
    if(k>=2)continue;
    if(k==1)cnt[l]--;
    rep(i,0,26)update(1,1,n,x,y,0,i);
    if(k==0)
    {
      lld curr=x;
      rep(i,0,26)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
      for(i=25;i>=0;i--)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
    }
    else
    {
      lld curr=x;
      rep(i,0,26)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
      update(1,1,n,curr,curr,1,l);
      curr++;
      for(i=25;i>=0;i--)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
    }
  }
  ans(1,1,n);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define N 400009
#define BLOCK 350
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld r,j,l,x,y,m,n,s,q,i,z,p,k,t,w,sz;string s1,s2;
lld tree[N][27],cnt[27],lazy[N][27];
lld build(lld node,lld l,lld r,lld pos)
{
  lazy[node][pos]=-1;
  if(l==r)
  {
    tree[node][pos]=(s1[l]-'a'==pos)?1:0;
    return 0;
  }
  lld mid=(l+r)/2;
  build(2*node,l,mid,pos),build(2*node+1,mid+1,r,pos);
  tree[node][pos]=tree[2*node][pos]+tree[2*node+1][pos];
}
lld query(lld node,lld l,lld r,lld left,lld right,lld pos)
{
  if(lazy[node][pos]!=-1)
  {
    tree[node][pos]=(r-l+1)*lazy[node][pos];
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
    }
    lazy[node][pos]=-1;
  }
  if(left>r||l>right)return 0;
  if(left<=l&&right>=r)
  {
    return tree[node][pos];
  }
  lld mid=(l+r)/2;
  return query(2*node,l,mid,left,right,pos)+query(2*node+1,mid+1,r,left,right,pos);
}
lld update(lld node,lld l,lld r,lld left,lld right,lld val,lld pos)
{
  if(lazy[node][pos]!=-1)
  {
    tree[node][pos]=(r-l+1)*lazy[node][pos];
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
    }
    lazy[node][pos]=-1;
  }
  if(left>r||l>right)return 0;
  if(left<=l&&right>=r)
  {
    tree[node][pos]=(r-l+1)*val;
    if(l!=r)
    {
      lazy[2*node][pos]=lazy[2*node+1][pos]=val;
    }
    return 0;
  }
  lld mid=(l+r)/2;
  update(2*node,l,mid,left,right,val,pos),update(2*node+1,mid+1,r,left,right,val,pos);
  tree[node][pos]=tree[2*node][pos]+tree[2*node+1][pos];
}
lld ans(lld node,lld l,lld r)
{
  for(lld pos=0;pos<26;pos++)
  {
    if(lazy[node][pos]!=-1)
    {
      tree[node][pos]=(r-l+1)*lazy[node][pos];
      if(l!=r)
      {
        lazy[2*node][pos]=lazy[2*node+1][pos]=lazy[node][pos];
      }
      lazy[node][pos]=-1;
    }
  }
  if(l==r)
  {
    rep(i,0,26)if(tree[node][i]==1)cout<<(char)('a'+i);
    return 0;
  }lld mid=(l+r)/2;
  ans(2*node,l,mid),ans(2*node+1,mid+1,r);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  cin>>n>>q>>s1;
  s1=" "+s1;
  rep(i,0,26)build(1,1,n,i);
  while(q--)
  {
    cin>>x>>y;
    rep(i,0,26)cnt[i]=query(1,1,n,x,y,i);
    k=0;
    rep(i,0,26)
    {
      if(cnt[i]%2)l=i,k++;
    }
    if(k>=2)continue;
    rep(i,0,26)update(1,1,n,x,y,0,i);
    if(k==0)
    {
      lld curr=x;
      rep(i,0,26)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
      for(i=25;i>=0;i--)
      {
        if(!cnt[i])continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
    }
    else
    {
      lld curr=x;
      rep(i,0,26)
      {
        if(!cnt[i]||l==i)continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
      update(1,1,n,curr,curr,1,l);
      curr++;
      for(i=25;i>=0;i--)
      {
        if(!cnt[i]||l==i)continue;
        update(1,1,n,curr,curr+(cnt[i]/2)-1,1,i);
        curr+=(cnt[i]/2);
      }
    }
  }
  ans(1,1,n);
}