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>
T rd() {
  T nmb = 0;
  int sgn = 0;
  char chr = getchar();
  while (!isdigit(chr)) {
    if (chr == '-') sgn = 1;
    chr = getchar();
  }
  while (isdigit(chr)) {
    nmb = (nmb << 3) + (nmb << 1) + chr - '0';
    chr = getchar();
  }
  return sgn ? -nmb : nmb;
}
template <typename T>
void wt(T nmb) {
  if (nmb > 9) wt(nmb / 10);
  putchar(nmb % 10 + '0');
}
template <typename T>
void cmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
void cmin(T &x, T y) {
  x = x < y ? x : y;
}
void proc_status() {
  ifstream t("/proc/self/status");
  cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>())
       << endl;
}
const int N = 1e5 + 5, K = 30;
char S[N];
int cnt = 1, lst = 1;
int ch[N << 1][K], mx[N << 1], loc[N << 1], pre[N << 1];
void insert(int c, int lc) {
  int p = lst, np = ++cnt;
  mx[np] = mx[p] + 1, loc[np] = lc;
  lst = np;
  for (; p && !ch[p][c]; p = pre[p]) ch[p][c] = np;
  if (!p)
    pre[np] = 1;
  else {
    int q = ch[p][c];
    if (mx[q] == mx[p] + 1)
      pre[np] = q;
    else {
      int nq = ++cnt;
      mx[nq] = mx[p] + 1, loc[nq] = loc[q];
      memcpy(ch[nq], ch[q], sizeof ch[q]);
      pre[nq] = pre[q];
      pre[q] = pre[np] = nq;
      for (; p && ch[p][c] == q; p = pre[p]) ch[p][c] = nq;
    }
  }
}
vector<int> g[N << 1];
namespace SGT {
int rt[N << 1];
int val[N << 7], lc[N << 7], rc[N << 7], Cnt;
void add(int &r, int x, int y, int k) {
  r = ++Cnt;
  if (x == y) {
    val[r] = 1;
    return;
  }
  int m = (x + y) >> 1;
  if (k <= m)
    add(lc[r], x, m, k);
  else
    add(rc[r], m + 1, y, k);
  val[r] = val[lc[r]] + val[rc[r]];
}
int merge(int r1, int r2, int x, int y) {
  if (!r1 || !r2) return r1 | r2;
  int t = ++Cnt;
  if (x == y) {
    val[t] = 1;
    return t;
  }
  int m = (x + y) >> 1;
  lc[t] = merge(lc[r1], lc[r2], x, m);
  rc[t] = merge(rc[r1], rc[r2], m + 1, y);
  val[t] = val[lc[t]] + val[rc[t]];
  return t;
}
int query(int r, int x, int y, int u, int v) {
  if (!r || u > v) return 0;
  if (u <= x && y <= v) return val[r];
  int m = (x + y) >> 1;
  int res = 0;
  if (u <= m) res += query(lc[r], x, m, u, v);
  if (m < v) res += query(rc[r], m + 1, y, u, v);
  return res;
}
}  // namespace SGT
using namespace SGT;
int n;
void dfs(int x) {
  for (int i = g[x].size() - 1; ~i; --i) {
    int k = g[x][i];
    dfs(k);
    rt[x] = merge(rt[x], rt[k], 1, n);
  }
}
const int L = 2e5 + 5;
char T[L];
int ans[L], slen, Ch;
int main() {
  scanf("%s", S + 1);
  n = strlen(S + 1);
  for (int i = 1; i <= n; ++i) insert(S[i] - 'a' + 1, i);
  add(rt[1], 1, n, loc[1]);
  for (int i = 2; i <= cnt; ++i)
    g[pre[i]].push_back(i), add(rt[i], 1, n, loc[i]);
  dfs(1);
  int m = rd<int>();
  while (m--) {
    int l = rd<int>(), r = rd<int>();
    scanf("%s", T + 1);
    int Len = strlen(T + 1);
    int pos = 1;
    slen = Ch = 0;
    int Flg = 1;
    for (int i = 1; i <= Len; ++i) {
      int To = ch[pos][T[i] - 'a' + 1];
      if (!To || !query(rt[To], 1, n, l + i - 1, r)) Flg = 0;
      for (int k = T[i] - 'a' + 2; k <= 26; ++k) {
        int Tox = ch[pos][k];
        if (Tox && query(rt[Tox], 1, n, l + i - 1, r)) {
          slen = i, Ch = k;
          break;
        }
      }
      if (!Flg) break;
      pos = To;
    }
    if (Flg) {
      for (int k = 1; k <= 26; ++k) {
        int Tox = ch[pos][k];
        if (Tox && query(rt[Tox], 1, n, l + Len, r)) {
          slen = Len + 1, Ch = k;
          break;
        }
      }
    }
    if (!slen) {
      puts("-1");
      continue;
    }
    for (int i = 1; i < slen; ++i) printf("%c", T[i]);
    printf("%c\n", Ch + 'a' - 1);
  }
  return 0;
}