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 long long maxn = 1e5 + 5;
struct SAMnode {
  long long len, f, s[30];
};
SAMnode t[maxn << 1];
long long las = 1, tot = 1;
void ins(char cc) {
  long long c = cc - 'a';
  long long p = las, np = ++tot;
  las = np;
  t[np].len = t[p].len + 1;
  for (; p && !t[p].s[c]; p = t[p].f) t[p].s[c] = np;
  if (!p) {
    t[np].f = 1;
  } else {
    long long q = t[p].s[c];
    if (t[q].len == t[p].len + 1) {
      t[np].f = q;
    } else {
      long long nq = ++tot;
      t[nq] = t[q];
      t[nq].len = t[p].len + 1;
      for (; p && t[p].s[c] == q; p = t[p].f) t[p].s[c] = nq;
      t[np].f = t[q].f = nq;
    }
  }
  return;
}
vector<long long> adj[maxn << 1];
void build() {
  for (int i = 2; i <= tot; i++) {
    adj[t[i].f].push_back(i);
  }
  return;
}
struct TreeNode {
  long long ls, rs, sum;
};
TreeNode tr[maxn << 6];
long long pol;
long long newnode() {
  tr[++pol].sum = 0;
  tr[pol].ls = tr[pol].rs = 0;
  return pol;
}
void pushup(long long p) {
  tr[p].sum = tr[tr[p].ls].sum + tr[tr[p].rs].sum;
  return;
}
void upd(long long p, long long l, long long r, long long x, long long add) {
  if (l == r) {
    tr[p].sum += add;
    return;
  }
  long long mid = (l + r) >> 1;
  if (x <= mid) {
    if (!tr[p].ls) tr[p].ls = newnode();
    upd(tr[p].ls, l, mid, x, add);
  } else {
    if (!tr[p].rs) tr[p].rs = newnode();
    upd(tr[p].rs, mid + 1, r, x, add);
  }
  pushup(p);
  return;
}
long long que(long long p, long long pl, long long pr, long long l,
              long long r) {
  if (pl > pr) return 0;
  if (!p) return 0;
  if (pl <= l && r <= pr) {
    return tr[p].sum;
  }
  long long mid = (l + r) >> 1, res = 0;
  if (pl <= mid) {
    res += que(tr[p].ls, pl, pr, l, mid);
  }
  if (pr > mid) {
    res += que(tr[p].rs, pl, pr, mid + 1, r);
  }
  return res;
}
long long rt[maxn << 1];
long long merge(long long x, long long y) {
  if (!x || !y) return x + y;
  long long nrt = ++pol;
  tr[nrt].sum = tr[x].sum;
  tr[nrt].sum += tr[y].sum;
  tr[nrt].ls = merge(tr[x].ls, tr[y].ls);
  tr[nrt].rs = merge(tr[x].rs, tr[y].rs);
  pushup(nrt);
  return nrt;
}
char ss[maxn], tt[maxn << 1];
long long slen, tlen, ql, qr, q;
void dfs1(long long now) {
  for (int i = 0; i < adj[now].size(); i++) {
    long long tp = adj[now][i];
    dfs1(tp);
    rt[now] = merge(rt[now], rt[tp]);
  }
  return;
}
long long ans[maxn];
bool flag = 0;
void dfs2(long long now, long long nlen) {
  if (flag) return;
  if (nlen == tlen) {
    for (int i = 0; i < 26; i++) {
      if (t[now].s[i] && que(rt[t[now].s[i]], ql + nlen, qr, 1, slen) > 0) {
        if (flag) return;
        ans[nlen + 1] = (char)('a' + i);
        for (int j = 1; j <= nlen + 1; j++) {
          putchar(ans[j]);
        }
        puts("");
        flag = 1;
        return;
      }
    }
    return;
  }
  long long c = tt[nlen + 1] - 'a';
  if (t[now].s[c] && que(rt[t[now].s[c]], ql + nlen, qr, 1, slen) > 0) {
    ans[nlen + 1] = tt[nlen + 1];
    dfs2(t[now].s[c], nlen + 1);
  }
  for (int i = c + 1; i < 26; i++) {
    if (t[now].s[i] && que(rt[t[now].s[i]], ql + nlen, qr, 1, slen) > 0) {
      if (flag) return;
      ans[nlen + 1] = (char)('a' + i);
      for (int j = 1; j <= nlen + 1; j++) {
        putchar(ans[j]);
      }
      puts("");
      flag = 1;
      return;
    }
  }
  return;
}
int main() {
  scanf("%s", ss + 1);
  slen = strlen(ss + 1);
  for (int i = 1; i <= slen; i++) {
    ins(ss[i]);
  }
  build();
  for (int i = 1; i <= tot; i++) {
    rt[i] = newnode();
  }
  long long nnow = 1;
  for (int i = 1; i <= slen; i++) {
    nnow = t[nnow].s[ss[i] - 'a'];
    upd(rt[nnow], 1, slen, i, 1);
  }
  dfs1(1);
  nnow = 1;
  for (int i = 1; i <= slen; i++) {
    nnow = t[nnow].s[ss[i] - 'a'];
  }
  scanf("%lld", &q);
  while (q--) {
    scanf("%lld %lld", &ql, &qr);
    scanf("%s", tt + 1);
    tlen = strlen(tt + 1);
    flag = 0;
    dfs2(1, 0);
    if (!flag) {
      puts("-1");
    }
  }
  return 0;
}