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;
inline int read() {
  int x = 0, f = 1;
  char p = getchar();
  while (!isdigit(p)) {
    if (p == '-') f = -1;
    p = getchar();
  }
  while (isdigit(p)) x = (x << 3) + (x << 1) + (p ^ 48), p = getchar();
  return x * f;
}
const int maxn = 400005;
char s[maxn], T[maxn];
int n, las = 1, tot = 1, id[maxn], root[maxn], ls[maxn * 30], rs[maxn * 30];
int sum[maxn * 30], A[maxn], t[maxn], node_cnt, pos[maxn];
struct node {
  int len, fa, ch[26];
} dian[maxn];
inline void modify(int c) {
  int p = las, np = las = ++tot;
  dian[np].len = dian[p].len + 1;
  for (; p && !dian[p].ch[c]; p = dian[p].fa) dian[p].ch[c] = np;
  if (!p)
    dian[np].fa = 1;
  else {
    int q = dian[p].ch[c];
    if (dian[q].len == dian[p].len + 1)
      dian[np].fa = q;
    else {
      int nq = ++tot;
      dian[nq] = dian[q];
      dian[nq].len = dian[p].len + 1;
      dian[np].fa = dian[q].fa = nq;
      for (; p && dian[p].ch[c] == q; p = dian[p].fa) dian[p].ch[c] = nq;
    }
  }
}
inline void insert(int &x, int l, int r, int p) {
  if (!x) x = ++node_cnt;
  sum[x]++;
  if (l == r) return;
  if (p <= ((l + r) >> 1))
    insert(ls[x], l, ((l + r) >> 1), p);
  else
    insert(rs[x], ((l + r) >> 1) + 1, r, p);
}
inline int merge(int x, int y) {
  if (!x || !y) return x + y;
  int z = ++node_cnt;
  sum[z] = sum[x] + sum[y];
  ls[z] = merge(ls[x], ls[y]);
  rs[z] = merge(rs[x], rs[y]);
  return z;
}
inline int query(int x, int l, int r, int L, int R) {
  if (L > R) return 0;
  if (L <= l && r <= R) return sum[x];
  int ans = 0;
  if (L <= ((l + r) >> 1)) ans += query(ls[x], l, ((l + r) >> 1), L, R);
  if (R > ((l + r) >> 1)) ans += query(rs[x], ((l + r) >> 1) + 1, r, L, R);
  return ans;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) modify(s[i] - 'a'), insert(root[las], 1, n, i);
  for (int i = 1; i <= tot; i++) t[dian[i].len]++;
  for (int i = 1; i <= n; i++) t[i] += t[i - 1];
  for (int i = tot; i >= 1; i--) A[t[dian[i].len]--] = i;
  for (int i = tot; i >= 1; i--)
    if (dian[A[i]].fa)
      root[dian[A[i]].fa] = merge(root[dian[A[i]].fa], root[A[i]]);
  int tim = read();
  pos[0] = 1;
  while (tim--) {
    int l = read(), r = read();
    scanf("%s", T + 1);
    int m = strlen(T + 1), lim = m;
    for (int i = 1, cur = 1; i <= m; i++) {
      if (dian[cur].ch[T[i] - 'a'])
        cur = dian[cur].ch[T[i] - 'a'], pos[i] = cur;
      else {
        lim = i - 1;
        break;
      }
    }
    int flag = 0;
    for (int i = lim; i >= 0; i--) {
      if (flag) break;
      for (int j = (i == m) ? 0 : (T[i + 1] - 'a' + 1); j < 26; j++) {
        if (query(root[dian[pos[i]].ch[j]], 1, n, l + i, r)) {
          flag = 1;
          for (int k = 1; k <= i; k++) putchar(T[k]);
          putchar('a' + j);
          printf("\n");
          break;
        }
      }
    }
    if (!flag) printf("-1\n");
  }
  return 0;
}