import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto S = 'a' ~ readln.chomp ~ 'a';
    auto N = readln.chomp.to!int;
    auto A = iota(N).map!(_ => readln.split.map!(to!int).array).array;

    auto M = S.length.to!int;
    auto B = (M-1).iota.map!(i => ((S[i].to!int - S[i+1].to!int) % 26 + 26) % 26).array;

    auto uf = new UnionFind(M-1);

    foreach (i; 0..(M-1)/2) {
        uf.unite(i, M-i-2);
    }

    foreach (a; A) {
        uf.unite(a[0]-1, a[1]);
    }

    foreach (i; 0..M-1) if (uf.table[i] < 0) {
        if (uf.group[i].map!(j => B[j]).sum % 26 != 0) {
            writeln("NO");
            return;
        }
    }

    writeln("YES");
}


class UnionFind {
    int N;
    int[] table;
    int[][] group;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
        group = N.iota.map!(i => [i]).array;
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        group[x] ~= group[y];
        group[y] = [];
        table[x] += table[y];
        table[y] = x;
    }
}

