Олимпиадный тренинг

Задача 39671. Substrings in a string


Given a string S = s1s2...sn and a set of queries like (l1, r 1, l2, r2). For each query, it is required to answer whether the substrings sl1...sr1 and sl2...sr2 are equal .


Input:
The first line contains the string S (1 <= |S| <= 105) consisting of lowercase Latin letters. 
The second line contains a natural number q (1 <= q <= 105) - the number of requests.
The next q lines contain 4 natural numbers each - l1, r1, l2, r2 ( 1 <= l1 <= r1 <= |S|, 1 <=l2 <= r< sub>2 <= |S|).

Output:
For each query, print '+' if the substrings are equal, and '-' otherwise.

Examples:
 
Input Output
abacaba
4
1 1 7 7
1 3 5 7
3 4 4 5
1 7 1 7
++-+