Problem: Ringo has a string S.

He can perform the following N kinds of operations any number of times in any order.

* Operation i: For each of the characters from the L_i-th through the R_i-th characters in S, replace it with its succeeding letter in the English alphabet. (That is, replace `a` with `b`, replace `b` with `c` and so on.) For `z`, we assume that its succeeding letter is `a`.



Ringo loves palindromes and wants to turn S into a palindrome. Determine whether this is possible.

Constraints

* 1 \leq |S| \leq 10^5
* S consists of lowercase English letters.
* 1 \leq N \leq 10^5
* 1 \leq L_i \leq R_i \leq |S|

Input

Input is given from Standard Input in the following format:


S
N
L_1 R_1
L_2 R_2
:
L_N R_N


Output

Print `YES` if it is possible to turn S into a palindrome; print `NO` if it is impossible.

Examples

Input

bixzja
2
2 3
3 6


Output

YES


Input

abc
1
2 2


Output

NO


Input

cassert
4
1 2
3 4
1 1
2 2


Output

YES

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int INF = (int)1.01e9;

mt19937 rnd;

bool solve(string s, vector<pair<int, int> > a) {
    int n = s.length();
    int m = a.size();

    int k = n / 2;
    for (int i = 0; i < m; i++) {
        if (a[i].first <= n - 1 - a[i].first && a[i].second >= n - 1 - a[i].second) {
            if (a[i].first <= n - 1 - a[i].second) {
                a[i].second = n - 1 - a[i].second - 1;
            } else {
                a[i].first = n - 1 - a[i].first + 1;
            }
        }
        if (a[i].first <= a[i].second && a[i].first >= n - 1 - a[i].first) {
            swap(a[i].first, a[i].second);
            a[i].first = n - 1 - a[i].first;
            a[i].second = n - 1 - a[i].second;
        }
        assert(a[i].first > a[i].second || a[i].second < k);
    }

    vector<int> b(k);
    for (int i = 0; i < k; i++) {
        b[i] = (s[i] - s[n - 1 - i] + 26) % 26;
    }
    vector<int> d(k);
    for (int i = 0; i < k; i++) {
        d[i] = i == 0 ? b[i] : (b[i] - b[i - 1] + 26) % 26;
    }

    vector<vector<int> > e(k + 1);
    for (int i = 0; i < m; i++) {
        if (a[i].first > a[i].second) continue;
        e[a[i].first].push_back(a[i].second + 1);
        e[a[i].second + 1].push_back(a[i].first);
    }
    vector<char> can(k + 1);
    vector<int> vct;
    function<void(int)> dfs1 = [&](int v) {
        if (can[v]) return;
        vct.push_back(v);
        can[v] = 1;
        for (int to : e[v]) dfs1(to);
    };
    dfs1(k);
    for (int i = k - 1; i >= 0; i--) {
        if (can[i]) continue;
        vct.clear();
        dfs1(i);
        int sum = 0;
        for (int v : vct) sum += d[v];
        if (sum % 26 != 0 || sum > 0 && vct.size() == 1) return 0;
    }
    return 1;
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    string s;
    while (cin >> s) {
        int m;
        cin >> m;
        vector<pair<int, int> > a(m);
        for (int i = 0; i < m; i++) {
            cin >> a[i].first >> a[i].second;
            a[i].first--;
            a[i].second--;
        }

        puts(solve(s, a) ? "YES" : "NO");
    }


#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}