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>
#pragma GCC optimize - O3
using namespace std;
using ll = int64_t;
using ld = double;
using ull = uint64_t;
using Hash = ull;
const Hash HSH = 237;
const int N = 100228;
int id[N];
int revid[N];
pair<int, int> p[N];
int a[4 * N];
vector<int> tr[4 * N];
void build(int v, int l, int r) {
  for (int i = l; i < r; ++i) {
    tr[v].push_back(revid[i]);
  }
  tr[v].push_back(N);
  sort(tr[v].begin(), tr[v].end());
  if (l == r - 1) {
    return;
  }
  int md = (l + r) / 2;
  build(v * 2, l, md);
  build(v * 2 + 1, md, r);
}
int query(int v, int l, int r, int lx, int rx, int lb) {
  if (l >= rx || lx >= r) {
    return N;
  }
  if (lx <= l && r <= rx) {
    return *lower_bound(tr[v].begin(), tr[v].end(), lb);
  }
  int md = (l + r) / 2;
  return min(query(v * 2, l, md, lx, rx, lb),
             query(v * 2 + 1, md, r, lx, rx, lb));
}
int bound(int l, int r, int ind, int x) {
  while (l < r) {
    int md = (l + r) / 2;
    if (a[id[md] + ind] >= x) {
      r = md;
    } else {
      l = md + 1;
    }
  }
  return l;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(20);
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; ++i) {
    a[i] = s[i] - 'a' + 1;
    revid[i] = a[i];
    id[i] = i;
  }
  for (int i = 1; i <= n; i *= 2) {
    for (int j = 0; j < n; ++j) {
      p[j].first = revid[j];
      int nj = j + i;
      if (nj >= n) {
        p[j].second = -1;
      } else {
        p[j].second = revid[nj];
      }
    }
    sort(id, id + n, [&](int x, int y) { return p[x] < p[y]; });
    int cv = 0;
    for (int i = 0; i < n; ++i) {
      cv += (i != 0) && (p[id[i]] != p[id[i - 1]]);
      revid[id[i]] = cv;
    }
  }
  build(1, 0, n);
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int ls, rs;
    cin >> ls >> rs;
    --ls;
    string st;
    cin >> st;
    int qn = st.length();
    int l = 0, r = n;
    int ans = -1;
    int len = -1;
    for (int j = 0; j <= qn; ++j) {
      int x = 0;
      if (j < qn) {
        x = st[j] - 'a' + 1;
      }
      int nr = bound(l, r, j, x + 1);
      int qv = query(1, 0, n, ls, rs, nr);
      if (qv < r) {
        ans = qv;
        len = j;
      }
      r = nr;
      l = bound(l, r, j, x);
      if (--rs <= ls) {
        break;
      }
    }
    if (ans == -1) {
      cout << -1 << "\n";
    } else {
      for (int j = 0; j <= len; ++j) {
        cout << s[id[ans] + j];
      }
      cout << "\n";
    }
  }
}