import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;
bool test1(int[] s, long l, long r, long n) {
    int offset = (26 + s[l] - s[r])%26;
    foreach(i; iota(n)) {
        if(s[l+i] != (s[r-i] + offset) % 26) {
            return false;
        }
    }
    return true;
}

bool test(int[] s, long[][] lr, long lOffset, long rOffset) {
    if(lOffset + rOffset + 1 >= s.length) {
        return true;
    }
    foreach(ref lri; lr) {
        if(lri[0] <= lOffset && lri[1] < s.length - rOffset - 1) {
            lri[0] = lri[1]+1;
            lri[1] = s.length - rOffset - 1;
        }
        if(lri[1] >= s.length - rOffset - 1 && lri[0] > lOffset) {
            lri[1] = lri[0]-1;
            lri[0] = lOffset;
        }
    }
    long len = s.length;
    foreach(lri; lr) {
        if(lOffset < lri[0] && lri[1] < s.length - rOffset - 1) {
            len = min(len, lOffset - lri[0], s.length - rOffset - 1 - lri[1]);
        }
    }
    if(!test1(s, lOffset, s.length - rOffset - 1, len)) {
        return false;
    }
    return test(s, lr, lOffset + len, rOffset + len);

}

void main(){
    auto S = readln().chomp();
    auto s = S.map!(a => (a - 'a').to!int)().array();

    auto n = readLong();
    long[][] lr;
    foreach(i; iota(n)) {
        lr ~= readLongs();
    }
    writeln(test(s, lr, 0, 0) ? "YES": "NO");
}

