atcoder#CF17FINALE. Combination Lock

Combination Lock

Score : 10001000 points

Problem Statement

Ringo has a string SS.

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

  • Operation ii: For each of the characters from the LiL_i-th through the RiR_i-th characters in SS, 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 SS into a palindrome. Determine whether this is possible.

Constraints

  • 1S1051 \leq |S| \leq 10^5
  • SS consists of lowercase English letters.
  • 1N1051 \leq N \leq 10^5
  • 1LiRiS1 \leq L_i \leq R_i \leq |S|

Input

Input is given from Standard Input in the following format:

SS

NN

L1L_1 R1R_1

L2L_2 R2R_2

::

LNL_N RNR_N

Output

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

bixzja
2
2 3
3 6
YES

For example, if we perform Operation 11, 22 and 11 in this order, SS changes as bixzjabjyzjabjzakbbkaakb and becomes a palindrome.

abc
1
2 2
NO
cassert
4
1 2
3 4
1 1
2 2
YES