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;
struct node {
  int l, r, w;
  node() { l = r = w = 0; }
};
const int maxn = 2e5 + 100;
struct SegmentTree {
  int sz = 0;
  node tr[maxn * 30];
  int rt[maxn];
  void Insert(int &o, int l, int r, int k, int v) {
    if (o == 0) o = ++sz;
    if (l == r) {
      tr[o].w += v;
      return;
    }
    int mid = (l + r) >> 1;
    if (k <= mid)
      Insert(tr[o].l, l, mid, k, v);
    else
      Insert(tr[o].r, mid + 1, r, k, v);
    tr[o].w = tr[tr[o].l].w + tr[tr[o].r].w;
  }
  int Query(int o, int l, int r, int L, int R) {
    if (o == 0) return 0;
    if (L <= l && r <= R) return tr[o].w;
    int mid = (l + r) >> 1;
    int ans = 0;
    if (L <= mid) ans += Query(tr[o].l, l, mid, L, R);
    if (R > mid) ans += Query(tr[o].r, mid + 1, r, L, R);
    return ans;
  }
  int merge(int x, int y) {
    if (!x || !y) return x ^ y;
    int o = ++sz;
    tr[o].w = tr[x].w + tr[y].w;
    tr[o].l = merge(tr[x].l, tr[y].l);
    tr[o].r = merge(tr[x].r, tr[y].r);
    return o;
  }
} st;
int pos[maxn];
struct suffixFA {
  int cnt = 1, last = 1;
  int endpos[maxn], tr[maxn][30], par[maxn], mx[maxn], c[maxn], id[maxn];
  int n;
  void extend(int x) {
    int np = ++cnt, p = last;
    endpos[np] = 1;
    mx[np] = mx[p] + 1;
    last = np;
    while (p && !tr[p][x]) tr[p][x] = np, p = par[p];
    if (!p)
      par[np] = 1;
    else {
      int q = tr[p][x];
      if (mx[q] == mx[p] + 1)
        par[np] = q;
      else {
        int nq = ++cnt;
        mx[nq] = mx[p] + 1;
        memcpy(tr[nq], tr[q], sizeof(tr[q]));
        par[nq] = par[q];
        par[q] = par[np] = nq;
        while (p && tr[p][x] == q) tr[p][x] = nq, p = par[p];
      }
    }
  }
  void topsort() {
    for (int i = 1; i <= cnt; i++) c[mx[i]]++;
    for (int i = 1; i <= n; i++) c[i] += c[i - 1];
    for (int i = 1; i <= cnt; i++) id[c[mx[i]]--] = i;
    for (int i = cnt; i; i--) endpos[par[id[i]]] += endpos[id[i]];
  }
  void solve() {
    topsort();
    for (int i = cnt; i; i--) {
      int k = st.merge(st.rt[par[id[i]]], st.rt[id[i]]);
      st.rt[par[id[i]]] = k;
    }
    int q;
    cin >> q;
    int l, r;
    string s;
    int u = 1;
    while (q--) {
      cin >> l >> r >> s;
      s.append("`");
      int u = 1, lastc = 0, flag = -2;
      for (int i = 0; i < s.length() && l + i <= r; i++) {
        for (int c = s[i] - 'a' + 1; c < 26; c++) {
          if (tr[u][c] != 0 && st.Query(st.rt[tr[u][c]], 1, n, l + i, r) != 0) {
            flag = i - 1;
            lastc = c;
            break;
          }
        }
        if (i + 1 != s.length()) {
          if (tr[u][s[i] - 'a'] == 0 ||
              st.Query(st.rt[tr[u][s[i] - 'a']], 1, n, l + i, r) == 0)
            break;
          u = tr[u][s[i] - 'a'];
        }
      }
      if (flag == -2)
        cout << "-1" << endl;
      else {
        for (int i = 0; i <= flag; i++) cout << s[i];
        cout << (char)(lastc + 'a') << endl;
      }
    }
  }
} sfa;
int main() {
  string str;
  cin >> str;
  sfa.n = str.length();
  for (int i = 0; i < str.length(); i++) {
    sfa.extend(str[i] - 'a');
    pos[i] = sfa.last;
  }
  for (int i = 0; i < str.length(); i++)
    st.Insert(st.rt[pos[i]], 1, sfa.n, i + 1, 1);
  sfa.solve();
  return 0;
}