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>
int fa[230000], son[230000][26], Len[230000], ton[230000], tp[230000],
    pa[230000], cc, tot, S;
char s[230000], T[230000];
void insert(int a) {
  int q = ++cc, now = S;
  S = q;
  Len[q] = Len[now] + 1;
  for (; now && !son[now][a]; now = fa[now]) son[now][a] = q;
  if (!now)
    fa[q] = 1;
  else {
    int t = son[now][a];
    if (Len[t] == Len[now] + 1)
      fa[q] = t;
    else {
      int Q = ++cc;
      Len[Q] = Len[now] + 1;
      memcpy(son[Q], son[t], sizeof(son[t]));
      fa[Q] = fa[t];
      fa[t] = fa[q] = Q;
      for (; son[now][a] == t; now = fa[now]) son[now][a] = Q;
    }
  }
}
int ls[230000 * 20], rs[230000 * 20], Rt[230000];
void update(int &i, int l, int r, int pos) {
  if (!i) i = ++tot;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update(ls[i], l, mid, pos);
  else
    update(rs[i], mid + 1, r, pos);
}
int merge(int x, int y) {
  if (!x || !y) return x | y;
  int i = ++tot;
  ls[i] = merge(ls[x], ls[y]);
  rs[i] = merge(rs[x], rs[y]);
  return i;
}
bool query(int i, int l, int r, int L, int R) {
  if (!i) return false;
  if (L <= l && r <= R) return true;
  int mid = (l + r) >> 1;
  return (L <= mid ? query(ls[i], l, mid, L, R) : 0) ||
         (mid < R ? query(rs[i], mid + 1, r, L, R) : 0);
}
inline int read() {
  int n = 0;
  char a;
  bool z = false;
  while (a = getchar()) {
    if (a > '9' || a < '0')
      if (z)
        break;
      else
        continue;
    if (!z) z = true;
    n = (n << 1) + (n << 3) + (a ^ 48);
  }
  return n;
}
int main() {
  S = cc = 1;
  scanf("%s", s + 1);
  int n = strlen(s + 1), now, len, Q, l, r;
  for (int i = 1; i <= n; ++i) {
    insert(s[i] - 'a');
    update(Rt[S], 1, n, i);
  }
  for (int i = 1; i <= cc; ++i) ++ton[Len[i]];
  for (int i = 1; i <= cc; ++i) ton[i] += ton[i - 1];
  for (int i = 1; i <= cc; ++i) tp[ton[Len[i]]--] = i;
  for (int i = cc; i > 1; --i) Rt[fa[tp[i]]] = merge(Rt[fa[tp[i]]], Rt[tp[i]]);
  Q = read();
  pa[0] = 1;
  while (Q--) {
    l = read();
    r = read();
    scanf("%s", T + 1);
    now = 1;
    len = strlen(T + 1);
    T[len + 1] = 'a' - 1;
    for (int i = 1; i <= len; ++i)
      if (son[now][T[i] - 'a'])
        now = son[now][T[i] - 'a'], pa[i] = now;
      else {
        len = i - 1;
        break;
      }
    for (int i = len; ~i; --i)
      for (int j = T[i + 1] - 'a' + 1; j < 26; ++j)
        if (son[pa[i]][j] && query(Rt[son[pa[i]][j]], 1, n, l + i, r)) {
          for (int k = 1; k <= i; ++k) putchar(T[k]);
          putchar('a' + j);
          putchar('\n');
          goto Y;
        }
    printf("-1\n");
    continue;
  Y:;
  }
  return 0;
}