Tiles


Submit solution

Points: 100 (partial)
Time limit: 0.5s
Memory limit: 256M

Author:
Problem type

Martin likes colorful tiles, and he decided to play a simple game with Andrew. There is a set of multicolored tiles of the same size, arranged in a row. Each tile has a color from \(1\) to \(26\).

To win the game, you need to compare faster than Andrew can \(Q\) substrings. Say whether the substring of tiles \([l_1 \dots r_1]\) is the same as \([l_2 \dots r_2]\). Martin is tired of winning against Andrew in this game, so Andrew asks you to play with him.

Input Specification

The first line contains no more than \(10^5\) lowercase Latin letters --- each character of the line represents the color of the \(i\)-th tile.

The second line contains one integer \(Q\) \((1 \leq Q \leq 10^5)\) --- the number of comparisons.

The following \(Q\) lines contain four integers \(l_1, r_1, l_2, r_2\) \((1 \leq l_1 \leq r_1 \leq |S|, 1 \leq l_2 \leq r_2 \leq |S|)\).

Output Specification

For each comparison in a separate line, you should print \(\texttt{Yes}\) if the given substrings are equal and \(\texttt{No}\) if they are not equal.

Sample Input 1

abcabc
3
1 3 4 6
1 2 5 6
2 3 5 6

Sample Output 1

Yes
No
Yes

Comments

There are no comments at the moment.