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 <class T>
inline bool Chkmax(T& x, const T& y) {
  return x < y ? x = y, true : false;
}
template <class T>
inline bool Chkmin(T& x, const T& y) {
  return x > y ? x = y, true : false;
}
const int maxn = 3e5 + 10;
const int maxm = 3e5 + 20;
int n;
namespace SAM {
int lson[maxn * 30], rson[maxn * 30];
int czj;
int len[maxn], go[maxn][27], S, cS, tot, fail[maxn];
int Sum[maxn * 30], root[maxn], cnt;
int net[maxm], head[maxn], to[maxm], ysh;
void insert(int& rt, int l, int r, int pos) {
  rt = ++cnt;
  if (l == r) return (void)(Sum[rt] = 1);
  int mid = (l + r) / 2;
  if (pos <= mid) insert(lson[rt], l, mid, pos);
  if (pos > mid) insert(rson[rt], mid + 1, r, pos);
  Sum[rt] = Sum[lson[rt]] + Sum[rson[rt]];
}
int merge(int x, int y, int l, int r) {
  if (l == r) {
    ++cnt;
    Sum[cnt] = Sum[x] + Sum[y];
    return cnt;
  }
  if (!x || !y) {
    return x + y;
  }
  int mid = (l + r) / 2;
  int tmp = ++cnt;
  lson[tmp] = merge(lson[x], lson[y], l, mid);
  rson[tmp] = merge(rson[x], rson[y], mid + 1, r);
  Sum[tmp] = Sum[lson[tmp]] + Sum[rson[tmp]];
  return tmp;
}
int Query(int rt, int l, int r, int L, int R) {
  if (L > R) return 0;
  if (L <= l && r <= R) return Sum[rt];
  int mid = (l + r) / 2, ans = 0;
  if (L <= mid) ans += Query(lson[rt], l, mid, L, R);
  if (R > mid) ans += Query(rson[rt], mid + 1, r, L, R);
  return ans;
}
void add(int x, int y) {
  net[++ysh] = head[x];
  head[x] = ysh;
  to[ysh] = y;
}
void dfs(int x, int fa) {
  for (int i = head[x]; i; i = net[i]) {
    int v = to[i];
    if (v == fa) continue;
    dfs(v, x);
    root[x] = merge(root[x], root[v], 1, n);
  }
  int tmp = Query(root[x], 1, n, 1, n / 2) + Query(root[x], 1, n, n / 2 + 1, n);
  if (tmp > 1) czj = max(czj, tmp * len[x]);
}
void extend(int c, int pos) {
  cS = ++tot;
  len[cS] = len[S] + 1;
  insert(root[tot], 1, n, pos);
  int Q = S;
  S = cS;
  while (!go[Q][c] && Q) go[Q][c] = cS, Q = fail[Q];
  if (!Q) {
    fail[cS] = 1;
    return;
  }
  int E = go[Q][c];
  if (len[E] == len[Q] + 1) {
    fail[cS] = E;
    return;
  }
  int k = ++tot;
  len[k] = len[Q] + 1;
  fail[k] = fail[E];
  fail[cS] = fail[E] = k;
  for (int i = 1; i <= 26; i++) go[k][i] = go[E][i];
  while (Q && go[Q][c] == E) go[Q][c] = k, Q = fail[Q];
}
}  // namespace SAM
using namespace SAM;
int check(int now, int L, int R, int cd) {
  return Query(root[now], 1, n, L + cd - 1, R);
}
string s;
int main() {
  S = tot = 1;
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  n = s.size();
  for (int i = 0; i <= s.size() - 1; i++) extend(s[i] - 'a' + 1, i + 1);
  for (int i = 1; i <= tot; i++) add(fail[i], i);
  int q;
  dfs(1, 0);
  cin >> q;
  while (q--) {
    int L, R;
    string t;
    cin >> L >> R;
    cin >> t;
    int now = 1;
    pair<int, int> ans;
    ans.first = -1;
    for (int i = 0; i <= t.size(); i++) {
      int ge;
      if (i == t.size())
        ge = 1;
      else
        ge = (t[i] - 'a' + 2);
      for (int j = ge; j <= 26; j++) {
        int tmp = now;
        tmp = go[tmp][j];
        if (tmp == 0) continue;
        if (check(tmp, L, R, i + 1)) {
          if (i > ans.first)
            ans.first = i, ans.second = j;
          else {
            if (i == ans.first)
              if (j < ans.second) ans.second = j;
          }
        }
      }
      if (i != t.size()) now = go[now][t[i] - 'a' + 1];
    }
  ppp:
    if (ans.first == -1)
      cout << -1 << '\n';
    else {
      for (int i = 1; i <= ans.first; i++) {
        cout << t[i - 1];
      }
      cout << (char)(ans.second + 'a' - 1) << '\n';
    }
  }
  return 0;
}