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;
const int N = 200010;
int cnt, np;
char s[N];
int ch[N][26], fa[N], l[N], rt[N], ls[N * 20], rs[N * 20], w[N], f[N], id[N];
inline int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch == '-' ? o = -1 : 0, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return o * x;
}
inline void insert(int c) {
  int x = np, y;
  l[np = ++cnt] = l[x] + 1;
  while (x && !ch[x][c]) ch[x][c] = np, x = fa[x];
  y = ch[x][c];
  if (!y)
    ch[x][c] = np;
  else if (l[y] == l[x] + 1)
    fa[np] = y;
  else {
    int nq = ++cnt;
    l[nq] = l[x] + 1;
    memcpy(ch[nq], ch[y], sizeof(ch[y]));
    fa[nq] = fa[y], fa[y] = fa[np] = nq;
    while (ch[x][c] == y) ch[x][c] = nq, x = fa[x];
  }
}
inline void insert(int l, int r, int p, int x, int &y) {
  y = ++cnt;
  if (l == r) return;
  ls[y] = ls[x], rs[y] = rs[x];
  int mid = (l + r) >> 1;
  if (p <= mid)
    insert(l, mid, p, ls[x], ls[y]);
  else
    insert(mid + 1, r, p, rs[x], rs[y]);
}
inline int merge(int x, int y) {
  if (!x || !y) return x | y;
  int z = ++cnt;
  ls[z] = merge(ls[x], ls[y]);
  rs[z] = merge(rs[x], rs[y]);
  return z;
}
inline bool query(int l, int r, int L, int R, int x) {
  if (!x) return 0;
  if (L <= l && r <= R) return 1;
  int mid = (l + r) >> 1;
  if (R <= mid)
    return query(l, mid, L, R, ls[x]);
  else if (L > mid)
    return query(mid + 1, r, L, R, rs[x]);
  else
    return query(l, mid, L, mid, ls[x]) | query(mid + 1, r, mid + 1, R, rs[x]);
}
int main() {
  int n, Q;
  scanf("%s%d", s + 1, &Q), n = strlen(s + 1);
  for (int i = 1; i <= n; i++) insert(s[i] - 'a'), w[np] = i;
  for (int i = 1; i <= cnt; i++) ++f[l[i]];
  for (int i = 1; i <= n; i++) f[i] += f[i - 1];
  for (int i = 1; i <= cnt; i++) id[f[l[i]]--] = i;
  for (int i = cnt; i; i--) {
    int x = id[i];
    if (w[x]) insert(1, n, w[x], rt[x], rt[x]);
    rt[fa[x]] = merge(rt[fa[x]], rt[x]);
  }
  while (Q--) {
    int l = gi(), r = gi(), m, p = 0, q = 0;
    scanf("%s", s + 1), m = strlen(s + 1) + 1;
    s[m] = 'a' - 1, m = min(m, r - l + 1);
    for (int i = 1, x = 0; i <= m; i++) {
      for (int j = s[i] - 'a' + 1; j < 26; j++)
        if (ch[x][j] && query(1, n, l + i - 1, r, rt[ch[x][j]])) {
          p = i, q = j;
          break;
        }
      if (i == m || !ch[x][s[i] - 'a']) break;
      x = ch[x][s[i] - 'a'];
    }
    s[p] = 'a' + q, s[p + 1] = '\0';
    puts(p ? s + 1 : "-1");
  }
  return 0;
}