Equal substrings
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given a string S = s[1]s[2]...s[n]
and a set of queries like (l[1]
, r[1]
, l[2]
, r[2]
).
For each query answer whether the substrings s[l1]
...s[r1]
and s[l2]
...s[r2]
are equal.
Input
The first line contains the string S, consisting of lowercase Latin letters. This string is non-empty and has a maximum length of 10^5
characters. The second line contains an integer q (1 ≤ q ≤ 50000) - the number of queries. Each of the following q lines contains the numbers l[1]
, r[1]
, l[2]
, r[2]
(1 ≤ l[1 ]
≤ r[1]
≤ |S|, 1 ≤ l[2]
≤ r[2]
≤ |S|).
Output
For each query print "+" if the corresponding substrings are equal, and "-" otherwise.
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 22%