Problem: Some programming website is establishing a secure communication protocol. For security reasons, they want to choose several more or less random strings.

Initially, they have a string s consisting of lowercase English letters. Now they want to choose q strings using the following steps, and you are to help them.

  1. A string x consisting of lowercase English letters and integers l and r (1 ≤ l ≤ r ≤ |s|) are chosen. 
  2. Consider all non-empty distinct substrings of the s_l s_{l + 1} … s_r, that is all distinct strings s_i s_{i+1} … s_{j} where l ≤ i ≤ j ≤ r. Among all of them choose all strings that are lexicographically greater than x. 
  3. If there are no such strings, you should print -1. Otherwise print the lexicographically smallest among them. 



String a is lexicographically less than string b, if either a is a prefix of b and a ≠ b, or there exists such a position i (1 ≤ i ≤ min(|a|, |b|)), such that a_i < b_i and for all j (1 ≤ j < i) a_j = b_j. Here |a| denotes the length of the string a.

Input

The first line of input contains a non-empty string s (1 ≤ |s| ≤ 10^{5}) consisting of lowercase English letters.

The second line contains an integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of strings to select.

Each of the next q lines contains two integers l, r (1 ≤ l ≤ r ≤ |s|) and a non-empty string x consisting of lowercase English letters. The total length of strings x for all queries does not exceed 2 ⋅ 10^{5}.

Output

Output q lines, each of them should contain the desired string or -1, if there is no such string.

Examples

Input

baa
5
1 2 ba
2 3 a
1 2 b
2 3 aa
1 3 b


Output

-1
aa
ba
-1
ba


Input

bacb
4
1 2 ba
2 3 ac
1 3 ac
3 4 c


Output

-1
c
b
cb


Input

bba
1
1 1 b


Output

-1

Note

Consider the first example.

The string s is "baa". The queries are as follows.

  1. We consider the substring s_1 s_2 that is "ba". It has substrings "b", "a" and "ba", since none of them is greater than the query string "ba", the answer is -1.
  2. We consider substring "aa". Among its substrings only "aa" is greater than the query string "a". So the answer is "aa".
  3. We consider substring "ba". Out of "b", "a" and "ba" only "ba" is greater than the query string "b", so the answer is "ba".
  4. We consider substring "aa". No substring of "aa" is greater than the query string "aa" so the answer is -1.
  5. We consider substring "baa" and it has (among others) substrings "ba", "baa" which are greater than the query string "b". Since "ba" is lexicographically smaller than "baa", the answer is "ba". 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
char G[524288 << 1], *g = G;
int A[262144], B[262144], D[262144], O[524288], S[262144], X[262144], Y[262144],
    a[262144][26], b[262144], d[262144], e[262144], f[262144], l[262144], m, n,
    o[262144], q, r[262144], t;
char c[262144];
bool Z[262144];
inline bool cmp(int u, int v) { return r[u] < r[v]; }
void dfs(int u) {
  D[u] = ++t, S[u] = 1;
  for (int i = A[u]; i; i = B[i]) dfs(i), S[u] += S[i];
}
inline void add(int u, int v) {
  for (u |= m; u; u >>= 1) O[u] = v;
}
inline int sum(int u, int v) {
  int x = 0;
  for (u += m - 1, v += m + 1; u ^ v ^ 1; u >>= 1, v >>= 1)
    ~u & 1 ? x = max(x, O[u ^ 1]) : 0, v & 1 ? x = max(x, O[v ^ 1]) : 0;
  return x;
}
bool find(char* C, int u, int v, int w, int& x, int& y, int z) {
  if (w < z && a[u][*C - 97] &&
      sum(D[a[u][*C - 97]], D[a[u][*C - 97]] + S[a[u][*C - 97]] - 1) >= v + w &&
      find(C + 1, a[u][*C - 97], v, w + 1, x, y, z))
    return true;
  for (int i = w == z ? 0 : *C - 96; i < 26; i++)
    if (a[u][i] && sum(D[a[u][i]], D[a[u][i]] + S[a[u][i]] - 1) >= v + w)
      return x = w, y = i, true;
  return false;
}
int main() {
  scanf("%s%d", c + 1, &q), m = 1, n = strlen(c + 1), *f = -1;
  for (int i = 1, u = 0, v; i <= n; i++) {
    b[e[i] = ++t] = b[u] + 1, c[i] -= 97;
    while (u >= 0 && !a[u][c[i]]) a[u][c[i]] = t, u = f[u];
    if (u < 0)
      u = t;
    else if (b[u] + 1 == b[a[u][c[i]]])
      f[t] = a[u][c[i]], u = t;
    else {
      b[++t] = b[u] + 1, f[t] = f[v = a[u][c[i]]], memcpy(a[t], a[v], 104);
      while (u >= 0 && a[u][c[i]] == v) a[u][c[i]] = t, u = f[u];
      f[v] = f[u = t - 1] = t;
    }
  }
  while (m < t + 2) m <<= 1;
  for (int i = 1; i <= t; i++) B[i] = A[f[i]], A[f[i]] = i;
  t = 0, dfs(0);
  for (int i = 1; i <= q; i++)
    scanf("%d%d%s", l + i, r + i, c + d[i - 1]),
        d[i] = d[i - 1] + strlen(c + d[i - 1]), o[i] = i;
  sort(o + 1, o + q + 1, cmp);
  for (int i = 1, j = 1; i <= q;
       Z[o[i]] = find(c + d[o[i] - 1], 0, l[o[i]], 0, X[o[i]], Y[o[i]],
                      d[o[i]] - d[o[i] - 1]),
           i++)
    while (j <= r[o[i]]) add(D[e[j]], j), j++;
  for (int i = 1; i <= q; i++, *g++ = '\n')
    Z[i]                 ? strncpy(g, c + d[i - 1], X[i]), g += X[i],
        *g++ = Y[i] + 97 : (*g++ = '-', *g++ = '1');
  fwrite(G, g - G, 1, stdout);
  return 0;
}