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". 
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  int w = 0;
  char ch = 0;
  while (ch < '0' || ch > '9') w |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return w ? -x : x;
}
const int N = 200005;
const int Maxlg = 26;
const int M = 26;
int n, m, nedge, hed[N], num, len[N], ch[N][M], fa[N];
int last, cnt, rot[N], L[N], R[N], val[N], tot;
struct node {
  int sz, son[2];
} tr[N * Maxlg];
struct Edge {
  int to, nex;
} edge[N << 1];
char s[N], ss[N];
void extend(int i, int c) {
  int p = last;
  int np = ++num;
  len[np] = len[p] + 1;
  while (p && (!ch[p][c])) ch[p][c] = np, p = fa[p];
  if (!p)
    fa[np] = 1;
  else {
    int q = ch[p][c];
    if (len[q] == len[p] + 1)
      fa[np] = q;
    else {
      int nq = ++num;
      len[nq] = len[p] + 1;
      fa[nq] = fa[q];
      for (register int j = 0; j <= 25; j++) ch[nq][j] = ch[q][j];
      fa[q] = fa[np] = nq;
      while (p && (ch[p][c] == q)) ch[p][c] = nq, p = fa[p];
    }
  }
  val[last = np] = i;
}
void pushup(int nod) {
  tr[nod].sz = tr[tr[nod].son[0]].sz + tr[tr[nod].son[1]].sz;
}
void update(int l, int r, int fnod, int &nod, int x) {
  tr[nod = ++cnt] = tr[fnod];
  if (l == r) {
    tr[nod].sz++;
    return;
  }
  if (x <= ((l + r) >> 1))
    update(l, ((l + r) >> 1), tr[fnod].son[0], tr[nod].son[0], x);
  else
    update(((l + r) >> 1) + 1, r, tr[fnod].son[1], tr[nod].son[1], x);
  pushup(nod);
}
int query(int l, int r, int fnod, int nod, int ll, int rr) {
  if ((l == ll) && (r == rr)) return tr[nod].sz - tr[fnod].sz;
  if (rr <= ((l + r) >> 1))
    return query(l, ((l + r) >> 1), tr[fnod].son[0], tr[nod].son[0], ll, rr);
  else if (ll > ((l + r) >> 1))
    return query(((l + r) >> 1) + 1, r, tr[fnod].son[1], tr[nod].son[1], ll,
                 rr);
  else
    return query(l, ((l + r) >> 1), tr[fnod].son[0], tr[nod].son[0], ll,
                 ((l + r) >> 1)) +
           query(((l + r) >> 1) + 1, r, tr[fnod].son[1], tr[nod].son[1],
                 ((l + r) >> 1) + 1, rr);
}
void addedge(int a, int b) {
  edge[nedge].to = b;
  edge[nedge].nex = hed[a];
  hed[a] = nedge++;
}
void dfs(int k) {
  L[k] = ++tot;
  if (val[k])
    update(1, n, rot[tot - 1], rot[tot], val[k]);
  else
    rot[tot] = rot[tot - 1];
  for (register int i = hed[k]; ~i; i = edge[i].nex) {
    int v = edge[i].to;
    dfs(v);
  }
  R[k] = tot;
}
void solve(char *s, int l, int r) {
  int nwn = strlen(s);
  int nw = 1;
  int res = 0, pd = 0;
  for (register int i = 0; i <= nwn; i++) {
    if (l + i > r) break;
    for (register int j = (i == nwn) ? 0 : (s[i] - 'a' + 1); j <= 25; j++) {
      if (!ch[nw][j]) continue;
      int tmp = ch[nw][j];
      if (query(1, n, rot[L[tmp] - 1], rot[R[tmp]], l + i, r)) {
        res = i;
        pd = j + 1;
        break;
      }
    }
    if ((i == nwn) || (!ch[nw][s[i] - 'a'])) break;
    nw = ch[nw][s[i] - 'a'];
  }
  if (!pd)
    printf("-1\n");
  else {
    for (register int i = 0; i <= res - 1; i++) putchar(s[i]);
    putchar('a' + (pd - 1));
    putchar('\n');
  }
}
int main() {
  scanf("%s", &s);
  n = strlen(s);
  last = num = 1;
  for (register int i = 1; i <= n; i++) extend(i, s[i - 1] - 'a');
  nedge = 0;
  memset(hed, -1, sizeof(hed));
  for (register int i = 2; i <= num; i++) addedge(fa[i], i);
  dfs(1);
  scanf("%d", &m);
  for (register int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    scanf("%s", &ss);
    solve(ss, l, r);
  }
  return 0;
}
