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 = 2e5 + 6;
const int SN = 4e6;
const int cN = 26;
int n, pn, m;
struct Merge_Segment {
  int ch[SN][2], sum[SN], tot;
  int merge(int x, int y) {
    if (!x || !y) return x + y;
    int George = ++tot;
    ch[George][0] = merge(ch[x][0], ch[y][0]);
    ch[George][1] = merge(ch[x][1], ch[y][1]);
    sum[George] = (sum[ch[George][0]] | sum[ch[George][1]]);
    return George;
  }
  void add(int &id, int L, int R, int wz) {
    if (!id) id = ++tot;
    sum[id] = true;
    if (L == R) return;
    int mid = (L + R) / 2;
    if (wz <= mid)
      add(ch[id][0], L, mid, wz);
    else
      add(ch[id][1], mid + 1, R, wz);
  }
  bool query(int id, int L, int R, int l, int r) {
    if (id == 0) return 0;
    if (l <= L && R <= r) return sum[id];
    int mid = (L + R) / 2, res = 0;
    if (l <= mid) res |= query(ch[id][0], L, mid, l, r);
    if (r > mid) res |= query(ch[id][1], mid + 1, R, l, r);
    return res;
  }
} seg;
struct sam {
  int ch[N][cN], head[N], fa[N], len[N], las = 1, tot = 1;
  void copy(int x, int y) {
    for (int i = 0; i <= cN - 1; i++) ch[y][i] = ch[x][i];
    fa[y] = fa[x], len[y] = len[x];
  }
  void ins(int x, int y) {
    int p = las, now = las = ++tot;
    len[now] = len[p] + 1, seg.add(head[now], 1, n, y);
    for (; p && !ch[p][x]; p = fa[p]) ch[p][x] = now;
    if (!p)
      fa[now] = 1;
    else {
      int pto = ch[p][x];
      if (len[pto] == len[p] + 1)
        fa[now] = pto;
      else {
        int sp = ++tot;
        copy(pto, sp), len[sp] = len[p] + 1;
        fa[now] = fa[pto] = sp;
        for (; p && ch[p][x] == pto; p = fa[p]) ch[p][x] = sp;
      }
    }
  }
} t;
int q[N], c[N];
void work() {
  for (int i = 1; i <= t.tot; i++) c[t.len[i]]++;
  for (int i = 1; i <= t.tot; i++) c[i] += c[i - 1];
  for (int i = 1; i <= t.tot; i++) q[c[t.len[i]]--] = i;
  for (int i = t.tot; i >= 1; i--)
    t.head[t.fa[q[i]]] = seg.merge(t.head[t.fa[q[i]]], t.head[q[i]]);
}
int l, r, tot;
char s[N], g[N];
bool dfs(int now, int x) {
  if (x == pn) {
    for (int i = 0; i <= cN - 1; i++)
      if (t.ch[now][i] && seg.query(t.head[t.ch[now][i]], 1, n, l + x, r))
        return g[++tot] = i + 'a', 1;
    return 0;
  }
  if (t.ch[now][s[x] - 'a'] && dfs(t.ch[now][s[x] - 'a'], x + 1))
    return g[++tot] = s[x], 1;
  for (int i = s[x] - 'a' + 1; i <= cN - 1; i++)
    if (t.ch[now][i] && seg.query(t.head[t.ch[now][i]], 1, n, l + x, r))
      return g[++tot] = i + 'a', 1;
  return 0;
}
int main() {
  scanf("%s", s + 1), n = strlen(s + 1);
  for (int i = 1; i <= n; i++) t.ins(s[i] - 'a', i);
  work();
  scanf("%d", &m);
  while (m--) {
    tot = 0;
    scanf("%d%d", &l, &r);
    scanf("%s", s), pn = strlen(s);
    if (!dfs(1, 0))
      printf("-1");
    else
      for (int i = tot; i >= 1; i--) putchar(g[i]);
    puts("");
  }
  return 0;
}