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

#ifdef LOCAL
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define dbg(...) 17;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) { bool f = true; os << "{"; for (const auto &x : c) { if (!f) os << ", "; f = false; os << x; } return os << "}"; }
template<typename T> void debug(string s, T x) { cerr << s << " = " << x << "\n"; }
template<typename T, typename... Args> void debug(string s, T x, Args... args) { cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...); }
const int MOD = 26;
typedef decay<decltype(MOD)>::type T;
struct mi {
    T val;
    explicit operator T() const { return val; }
    mi() { val = 0; }
    mi(const long long& v) {
        val = (-MOD <= v && v <= MOD) ? v : v % MOD;
        if (val < 0) val += MOD; }
    friend ostream& operator<<(ostream& os, const mi& a) { return os << a.val; }
    friend bool operator==(const mi& a, const mi& b) { return a.val == b.val; }
    friend bool operator!=(const mi& a, const mi& b) { return !(a == b); }
    friend bool operator<(const mi& a, const mi& b) { return a.val < b.val; }
    mi operator-() const { return mi(-val); }
    mi& operator+=(const mi& m) {
        if ((val += m.val) >= MOD) val -= MOD;
        return *this; }
    mi& operator-=(const mi& m) {
        if ((val -= m.val) < 0) val += MOD;
        return *this; }
    mi& operator*=(const mi& m) { val = (long long) val * m.val % MOD;
        return *this; }
    friend mi pow(mi a, long long p) {
        mi ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p & 1) ans *= a;
        return ans; }
    friend mi inv(const mi& a) { assert(a != 0); return pow(a, MOD - 2); }
    mi& operator/=(const mi& m) { return (*this) *= inv(m); }
    friend mi operator+(mi a, const mi& b) { return a += b; }
    friend mi operator-(mi a, const mi& b) { return a -= b; }
    friend mi operator*(mi a, const mi& b) { return a *= b; }
    friend mi operator/(mi a, const mi& b) { return a /= b; }
};
template<class T, int SZ> struct LazySeg {
    T sum[2 * SZ], lazy[2 * SZ];
    LazySeg() {
        for (int i = 0; i < 2 * SZ; i++) {
            sum[i] = 0;
            lazy[i] = 0;
        }
    }
    void push(int ind, int L, int R) {
        sum[ind] += (R - L + 1) * lazy[ind];
        if (L != R) {
            lazy[2 * ind] += lazy[ind];
            lazy[2 * ind + 1] += lazy[ind];
        }
        lazy[ind] = 0;
    }
    void pull(int ind) {
        sum[ind] = sum[2 * ind] + sum[2 * ind + 1];
    }
    void build() {
        for (int i = SZ - 1; i >= 1; i--) {
            pull(i);
        }
    }
    void upd(int lo, int hi, T inc, int ind = 1, int L = 0, int R = SZ - 1) {
        push(ind, L, R);
        if (hi < L || R < lo) return ;
        if (lo <= L && R <= hi) {
            lazy[ind] = inc;
            push(ind, L, R);
            return;
        }
        int M = (L + R) / 2;
        upd(lo, hi, inc, 2 * ind, L, M);
        upd(lo, hi, inc, 2 * ind + 1, M + 1, R);
        pull(ind);
    }
    T qsum(int lo, int hi, int ind = 1, int L = 0, int R = SZ - 1) {
        push(ind, L, R);
        if (lo > R || L > hi) return 0;
        if (lo <= L && R <= hi) return sum[ind];
        int M = (L + R) / 2;
        return qsum(lo, hi, 2 * ind, L, M) + qsum(lo, hi, 2 * ind + 1, M + 1, R);
    }
};
int main() {
//    ios_base::sync_with_stdio(0); cin.tie(0);
//    freopen("file.in", "r", stdin);
    string s;
    cin >> s;
    int n;
    cin >> n;
    int len = s.size();
    vector<pair<int, int>> use;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        if (r < len / 2) {
            use.emplace_back(l, r);
            continue;
        }
        if (l >= (len + 1) / 2) {
            use.emplace_back(len - 1 - r, len - 1 - l);
            continue;
        }
        if (l == len - 1 - r) {
            continue;
        }
        if (l < len - 1 - r) {
            use.emplace_back(l, len - 1 - r - 1);
        } else {
            use.emplace_back(len - 1 - r, l - 1);
        }
    }
    int half = (len - 1) / 2 + 1;
    vector<vector<int>> loc(half);
    for (auto x: use) {
        loc[x.first].push_back(x.second);
    }
    for (int i = 0; i < half; i++) {
        sort(loc[i].begin(), loc[i].end());
        loc[i].erase(unique(loc[i].begin(), loc[i].end()), loc[i].end());
        while(loc[i].size() > 1) {
            int r = loc[i].back();
            loc[i].pop_back();
            int l = loc[i].back() + 1;
            loc[l].push_back(r);
        }
    }
    for (int i = 0; i < half; i++) {
        for (int r: loc[i]) {
            use.emplace_back(i, r);
        }
        loc[i].clear();
    }
    for (auto x: use) {
        loc[x.second].push_back(x.first);
    }
    use.clear();
    for (int i = half - 1; i >= 0; i--) {
        sort(loc[i].begin(), loc[i].end());
        loc[i].erase(unique(loc[i].begin(), loc[i].end()), loc[i].end());
        reverse(loc[i].begin(), loc[i].end());
        while (loc[i].size() > 1) {
            int l = loc[i].back();
            loc[i].pop_back();
            int r = loc[i].back() - 1;
            loc[r].push_back(l);
        }
    }
    for (int i = 0; i < half; i++) {
        for (int l: loc[i]) {
            use.emplace_back(l, i);
        }
        loc[i].clear();
    }
    string t;
    for (int i = len - 1; i >= len - half; i--) {
        t += s[i];
    }
    while (s.size() > half) {
        s.pop_back();
    }
    len = half;
    LazySeg<mi, (1 << 16)> seg;
    for (int i = 0; i < len; i++) {
        seg.upd(i, i, s[i] - '0');
    }
    sort(use.begin(), use.end());
    for (auto x: use) {
        int l = x.first;
        int r = x.second;
        int add = ((t[l] - '0') - seg.qsum(l, l).val + MOD) % MOD;
        seg.upd(l, r, add);
    }
    for (int i = 0; i < len; i++) {
        if (seg.qsum(i, i) != t[i] - '0') {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 13712