Score : 1000 points
Ringo has a string S.
He can perform the following N kinds of operations any number of times in any order.
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.
Input is given from Standard Input in the following format:
S N L_1 R_1 L_2 R_2 : L_N R_N
Print YES if it is possible to turn S into a palindrome; print NO if it is impossible.
bixzja 2 2 3 3 6
YES
For example, if we perform Operation 1, 2 and 1 in this order, S changes as bixzja → bjyzja → bjzakb → bkaakb and becomes a palindrome.
abc 1 2 2
NO
cassert 4 1 2 3 4 1 1 2 2
YES