#B3769. Lexicographical Substring Comparison
Lexicographical Substring Comparison
Lexicographical Substring Comparison
You are given two strings \(s\) and \(t\), and \(q\) queries.
For each query, you are provided four integers \(l_1\), \(r_1\), \(l_2\), and \(r_2\). You need to compare the substrings \(s[l_1, r_1]\) and \(t[l_2, r_2]\) in lexicographical order. Output First
if the substring of \(s\) is lexicographically smaller, Second
if the substring of \(t\) is smaller, and Equal
if they are the same.
Note: The notation \(s[l_1, r_1]\) refers to the substring of \(s\) from index \(l_1\) to \(r_1\) (both inclusive). Similarly for \(t[l_2, r_2]\).
inputFormat
The input consists of multiple lines:
- The first line contains the string
s
. - The second line contains the string
t
. - The third line contains an integer
q
, representing the number of queries. - The following
q
lines each contain four integers:l1, r1, l2, r2
, representing a query.
outputFormat
For each query, output a single line containing one of the following:
First
if \(s[l_1, r_1]\) is lexicographically smaller than \(t[l_2, r_2]\).Second
if \(t[l_2, r_2]\) is lexicographically smaller than \(s[l_1, r_1]\).Equal
if both substrings are identical.
sample
abc
abd
1
1 3 1 3
First
</p>