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 = 200020, K = 30;
int n, m, i, j, k, po, q, l, r, tmp;
char s[N], Ans[N];
struct SAM {
  int fa[N], ch[N][26], len[N], cnt, lst;
  int rt[N], h[N], t[N], v[N], sum[N * K], L[N * K], R[N * K];
  void Pushup(int x) { sum[x] = sum[L[x]] + sum[R[x]]; }
  int Insert(int a, int l, int r, int x) {
    a = ++po;
    if (l == r) {
      sum[a]++;
      return a;
    }
    int mid = l + r >> 1;
    if (x <= mid)
      L[a] = Insert(L[a], l, mid, x);
    else
      R[a] = Insert(R[a], mid + 1, r, x);
    Pushup(a);
    return a;
  }
  void Ins(int c, int id) {
    int np = ++cnt;
    int p = lst;
    lst = np;
    rt[np] = Insert(rt[np], 1, n, id);
    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[p] + 1 == len[q])
        fa[np] = q;
      else {
        int nq = ++cnt;
        memcpy(ch[nq], ch[q], sizeof(ch[nq]));
        fa[nq] = fa[q];
        len[nq] = len[p] + 1;
        fa[q] = fa[np] = nq;
        while (p && ch[p][c] == q) {
          ch[p][c] = nq;
          p = fa[p];
        }
      }
    }
  }
  void add(int a, int b) {
    t[++k] = h[a];
    h[a] = k;
    v[k] = b;
  }
  void Build() {
    for (i = 2; i <= cnt; i++) add(fa[i], i);
  }
  int Merge(int a, int b, int l, int r) {
    if (!a || !b) return a ^ b;
    int c = ++po;
    if (l == r) {
      sum[c] = sum[a] + sum[b];
      return c;
    }
    int mid = l + r >> 1;
    L[c] = Merge(L[a], L[b], l, mid);
    R[c] = Merge(R[a], R[b], mid + 1, r);
    Pushup(c);
    return c;
  }
  int Query(int rt, int l, int r, int x, int y) {
    if (x > y) return 0;
    if (!rt) return 0;
    if (x <= l && r <= y) return sum[rt];
    int mid = l + r >> 1, S = 0;
    if (x <= mid) S += Query(L[rt], l, mid, x, y);
    if (y > mid) S += Query(R[rt], mid + 1, r, x, y);
    return S;
  }
  void dfs(int i) {
    for (int j = h[i]; j; j = t[j]) {
      dfs(v[j]);
      rt[i] = Merge(rt[i], rt[v[j]], 1, n);
    }
  }
  void calc(int pos, int len) {
    if (tmp) return;
    if (len == m + 1) {
      for (int k = 0; k < 26 && !tmp; k++)
        if (ch[pos][k] && Query(rt[ch[pos][k]], 1, n, l + len - 1, r)) {
          tmp = 1;
          Ans[len] = k + 97;
          Ans[len + 1] = 0;
        }
      return;
    }
    if (ch[pos][s[len] - 97] &&
        Query(rt[ch[pos][s[len] - 97]], 1, n, l + len - 1, r)) {
      Ans[len] = s[len];
      calc(ch[pos][s[len] - 97], len + 1);
    }
    for (int k = s[len] - 97 + 1; k < 26 && !tmp; k++)
      if (ch[pos][k] && Query(rt[ch[pos][k]], 1, n, l + len - 1, r)) {
        tmp = 1;
        Ans[len] = k + 97;
        Ans[len + 1] = 0;
      }
  }
  void work() {
    for (m = 0; s[m + 1]; m++)
      ;
    for (i = 0; i <= m + 2; i++) Ans[i] = 0;
    tmp = 0;
    calc(1, 1);
    if (tmp)
      printf("%s\n", Ans + 1);
    else
      printf("-1\n");
  }
} T;
void init() {
  T.cnt = T.lst = 1;
  scanf("%s", s + 1);
  for (n = 0; s[n + 1]; n++)
    ;
  for (i = 1; i <= n; i++) T.Ins(s[i] - 97, i);
  T.Build();
  T.dfs(1);
}
void work() {
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%s", &l, &r, s + 1);
    T.work();
  }
}
int main() {
  init();
  work();
  return 0;
}