This page is still under construction.

Parts of this page are still being built. What you see may change.

Hacker

Time limit4sMemory limit512 MB

Summary
Simulate substring comparisons, substring copy from a fixed string, and range letter-increment operations on a mutable string of length N.
Level

Hard9 of 10

Topics
Segment tree, Hash map, String matching, Linked list
Solved
No attempts yet

Problem

A hacker has broken into Miltos's e-mail account again. Miltos decides to replace his password with a much stronger one. The old password WW is a string of NN lowercase Latin letters, and the new password starts as an exact copy of WW. Miltos applies QQ operations to the new password in order, and he asks you to simulate them.

There are three kinds of operations.

  • 1 i j k: compare the substring of the new password from position ii to position jj with the substring of the new password that starts at position kk and has length j−i+1j - i + 1. Print Y if the two substrings are equal, otherwise print N.
  • 2 i j k: replace positions ii to jj of the new password with the substring of the old password WW that starts at position kk and has length j−i+1j - i + 1.
  • 3 i j: advance every letter of the new password from position ii to position jj to the next letter, cyclically. The letter a becomes b, b becomes c, and z becomes a.

Positions are counted from 1. Every operation is valid, so 1≤i≤j≤N1 \le i \le j \le N, and operations of kind 1 and kind 2 satisfy k+j−i≤Nk + j - i \le N. The old password WW never changes, and the length of the new password is always NN.

Input

The first line contains the old password WW. The second line contains the number of operations QQ. Each of the next QQ lines contains one operation in one of the formats above.

Output

For every operation of kind 1, print Y or N on its own line, in the order the operations are given.

Examples1

  1. Example 1

    Input
    aaaaxazyzab
    8
    1 1 3 2
    2 1 3 7
    1 1 3 2
    1 2 4 8
    3 2 4
    1 2 4 9
    2 7 10 1
    1 6 8 8
    
    Expected output
    Y
    N
    Y
    Y
    Y