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>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
using namespace std;
int s_n;
char s[501000];
int rt[501000];
int ls[17001000], rs[17001000], ttot;
void add(int L, int R, int pos, int &cur) {
  if (!cur) cur = ++ttot;
  if (L == R) return;
  int mid = (L + R) >> 1;
  if (pos <= mid)
    add(L, mid, pos, ls[cur]);
  else
    add(mid + 1, R, pos, rs[cur]);
}
int merge(int L, int R, int cur1, int cur2) {
  if (!cur1 || !cur2 || L == R) return cur1 | cur2;
  int mid = (L + R) >> 1, nwcur = ++ttot;
  ls[nwcur] = merge(L, mid, ls[cur1], ls[cur2]);
  rs[nwcur] = merge(mid + 1, R, rs[cur1], rs[cur2]);
  return nwcur;
}
bool query(int L, int R, int l, int r, int cur) {
  if (!cur) return false;
  if (l <= L && R <= r) return true;
  if (R < l || r < L) return false;
  int mid = (L + R) >> 1;
  return query(L, mid, l, r, ls[cur]) || query(mid + 1, R, l, r, rs[cur]);
}
int son[501000][26], fa[501000], len[501000], lst = 1, tot = 1;
inline void ins(int c) {
  int np = ++tot, p = lst;
  lst = np, len[np] = len[p] + 1;
  add(1, s_n, len[np], rt[np]);
  while (p && !son[p][c]) son[p][c] = np, p = fa[p];
  if (!p) return fa[np] = 1, void();
  int q = son[p][c];
  if (len[q] == len[p] + 1) return fa[np] = q, void();
  int nq = ++tot;
  len[nq] = len[p] + 1;
  fa[nq] = fa[q], fa[q] = fa[np] = nq;
  memcpy(son[nq], son[q], sizeof(son[q]));
  while (p && son[p][c] == q) son[p][c] = nq, p = fa[p];
}
int bin[501000], id[501000];
inline void Sort() {
  for (register int i = 1; i <= tot; ++i) bin[len[i]]++;
  for (register int i = 1; i <= s_n; ++i) bin[i] += bin[i - 1];
  for (register int i = tot; i; --i) id[bin[len[i]]--] = i;
}
inline void Merge() {
  for (register int i = tot; i; --i) {
    int p = id[i];
    if (fa[p]) rt[fa[p]] = merge(1, s_n, rt[fa[p]], rt[p]);
  }
}
inline bool che(int p, int ll, int rr, int nwlen) {
  if (rr - (ll + nwlen - 1) + 1 <= 0) return false;
  return query(1, s_n, ll + nwlen - 1, rr, rt[p]);
}
int q;
int stk[501000], stop, stkc[501000];
bool appe[32];
int main() {
  scanf("%s", s + 1);
  s_n = strlen(s + 1);
  for (register int i = 1; i <= s_n; ++i) {
    ins(s[i] - 'a');
    appe[s[i] - 'a'] = true;
  }
  Sort();
  Merge();
  read(q);
  register int ll, rr, t_n;
  while (q--) {
    read(ll);
    read(rr);
    scanf("%s", s + 1);
    t_n = strlen(s + 1);
    stop = 0;
    int np = 1;
    stk[++stop] = np;
    for (register int i = 1; i <= t_n; ++i) {
      int c = s[i] - 'a';
      if (son[np][c] && che(son[np][c], ll, rr, i)) {
        np = son[np][c];
        stk[++stop] = np;
        continue;
      }
      break;
    }
    bool flag = false;
    for (register int i = stop; i; --i) {
      for (register int c = max(s[i] - 'a' + 1, 0); c < 26; ++c) {
        if (son[stk[i]][c] && che(son[stk[i]][c], ll, rr, i)) {
          for (register int j = 1; j < i; ++j) {
            putchar(s[j]);
          }
          int cc = c;
          putchar('a' + cc);
          puts("");
          flag = true;
          break;
        }
      }
      if (flag) break;
    }
    if (!flag) puts("-1");
  }
  return 0;
}