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;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar(), f = 0;
  for (; c < 48 || c > 57; c = getchar())
    if (!(c ^ 45)) f = 1;
  for (; c >= 48 && c <= 57; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  f ? x = -x : 0;
}
struct sam {
  int fa, len, ch[26];
} S[200005];
int St = 1, lst = 1;
struct seg {
  int ls, rs;
} t[5000005];
int rt[200005], tt;
int n, Q, nxt[200005], qwq[200005], sa[200005];
char c[100005];
inline void Motif(int &x, int l, int r, int dw) {
  x ? x : x = ++tt;
  if (l == r) return;
  if (dw <= ((l + r) >> 1))
    Motif(t[x].ls, l, (l + r) >> 1, dw);
  else
    Motif(t[x].rs, ((l + r) >> 1) + 1, r, dw);
}
inline int Query(int x, int l, int r, int dl, int dr) {
  if (dl > r || l > dr || !x)
    return 0;
  else if (dl <= l && r <= dr)
    return 1;
  return Query(t[x].ls, l, (l + r) >> 1, dl, dr) |
         Query(t[x].rs, ((l + r) >> 1) + 1, r, dl, dr);
}
inline int Merge(int x, int y, int l, int r) {
  int v;
  if (!x || !y)
    return x | y;
  else if (!(x ^ y))
    return x;
  else
    v = ++tt;
  return t[v].ls = Merge(t[x].ls, t[y].ls, l, (l + r) >> 1),
         t[v].rs = Merge(t[x].rs, t[y].rs, ((l + r) >> 1) + 1, r), v;
}
inline void samins(int c) {
  int p = lst, np = lst = ++St;
  S[np].len = S[p].len + 1, Motif(rt[np], 1, n, S[np].len);
  for (; p && !S[p].ch[c]; p = S[p].fa) S[p].ch[c] = np;
  int q = S[p].ch[c];
  if (!p) return (void)(S[np].fa = 1);
  if (S[q].len == S[p].len + 1) return (void)(S[np].fa = q);
  int nq = ++St;
  S[nq] = S[q], S[nq].len = S[p].len + 1, S[q].fa = S[np].fa = nq;
  for (; p && S[p].ch[c] == q; p = S[p].fa) S[p].ch[c] = nq;
}
inline void Debug(int x, int l, int r) {
  if (!x)
    ;
  else if (l == r)
    printf("%d ", l);
  else
    Debug(t[x].ls, l, (l + r) >> 1), Debug(t[x].rs, ((l + r) >> 1) + 1, r);
}
inline void sasrt() {
  for (int i = 1; i <= St; i++) ++qwq[S[i].len];
  for (int i = 1; i <= n; i++) qwq[i] += qwq[i - 1];
  for (int i = 1; i <= St; i++) sa[qwq[S[i].len]--] = i;
  for (int i = St; i; i--)
    rt[S[sa[i]].fa] = Merge(rt[S[sa[i]].fa], rt[sa[i]], 1, n);
}
int main() {
  scanf("%s", c + 1), n = strlen(c + 1), read(Q);
  for (int i = 1; i <= n; i++) samins(c[i] - 'a');
  sasrt();
  for (int l, r; Q--;) {
    read(l), read(r), scanf("%s", c + 1);
    int x = 1;
    int i, m = strlen(c + 1);
    for (i = 1;; i++) {
      nxt[i] = -1;
      for (int v = max(c[i] - 'a' + 1, 0); v < 26; v++) {
        int y = S[x].ch[v];
        if (y && Query(rt[y], 1, n, l + i - 1, r)) {
          nxt[i] = v;
          break;
        }
      }
      int y = i > m ? 0 : S[x].ch[c[i] - 'a'];
      if (!y || i == m + 1 || !Query(rt[y], 1, n, l + i - 1, r))
        break;
      else
        x = y;
    }
    for (; i && !~nxt[i]; i--)
      ;
    if (!i) {
      puts("-1");
      continue;
    }
    for (int j = 1; j < i; j++) putchar(c[j]);
    putchar(nxt[i] + 'a'), putchar('\n');
  }
  return 0;
}