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;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
char s[N];
int n;
struct seg {
  int l, r;
} t[N * 64];
int rt[N * 64], tot;
void upd(int &p, int l, int r, int x) {
  if (!p) p = ++tot;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (x <= mid)
    upd(t[p].l, l, mid, x);
  else
    upd(t[p].r, mid + 1, r, x);
}
int merge(int x, int y, int l, int r) {
  if (!x || !y) return x | y;
  int mid = (l + r) >> 1;
  int p = ++tot;
  t[p].l = merge(t[x].l, t[y].l, l, mid);
  t[p].r = merge(t[x].r, t[y].r, mid + 1, r);
  return p;
}
int ask(int p, int l, int r, int x, int y) {
  if (!p || x > y) return 0;
  if (l >= x && r <= y) return 1;
  int mid = (l + r) >> 1;
  if (x <= mid && ask(t[p].l, l, mid, x, y)) return 1;
  if (y > mid && ask(t[p].r, mid + 1, r, x, y)) return 1;
  return 0;
}
namespace sam {
constexpr int M = N << 1;
int ch[M][26], len[M], fa[M], sz[M];
int last, tot;
void init() {
  memset(ch, 0, (tot + 1) * sizeof(ch[0]));
  last = tot = 1;
}
void insert(int c) {
  int p = last, np = last = ++tot;
  len[np] = len[p] + 1;
  sz[np] = 1;
  upd(rt[np], 1, n, len[np]);
  while (p && !ch[p][c]) ch[p][c] = np, p = fa[p];
  if (!p) {
    fa[np] = 1;
    return;
  }
  int q = ch[p][c];
  if (len[p] + 1 == len[q]) {
    fa[np] = q;
    return;
  }
  int nq = ++tot;
  len[nq] = len[p] + 1;
  fa[nq] = fa[q];
  fa[q] = fa[np] = nq;
  memcpy(ch[nq], ch[q], sizeof(ch[q]));
  while (p && ch[p][c] == q) ch[p][c] = nq, p = fa[p];
}
int c[M], buc[M];
void rsort() {
  for (int i = 1; i <= tot; i++) c[i] = 0;
  for (int i = 1; i <= tot; i++) c[len[i]]++;
  for (int i = 1; i <= tot; i++) c[i] += c[i - 1];
  for (int i = 1; i <= tot; i++) buc[c[len[i]]--] = i;
}
}  // namespace sam
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> s;
  n = strlen(s);
  sam::init();
  for (int i = 0; i < n; i++) sam::insert(s[i] - 'a');
  sam::rsort();
  for (int i = sam::tot; i >= 2; i--) {
    int j = sam::buc[i];
    rt[sam::fa[j]] = merge(rt[sam::fa[j]], rt[j], 1, n);
  }
  int _;
  cin >> _;
  while (_--) {
    int l, r;
    string t;
    cin >> l >> r >> t;
    vector<int> nxt((int)t.size() + 1, -1);
    int p = 1;
    for (int i = 0; i <= (int)t.size(); i++) {
      int st = (i == (int)t.size() ? 0 : t[i] - 'a' + 1);
      for (int j = st; j < 26; j++) {
        int np = sam::ch[p][j];
        if (!np || !ask(rt[np], 1, n, l + i, r)) continue;
        nxt[i] = j;
        break;
      }
      if (i < (int)t.size()) {
        p = sam::ch[p][st - 1];
        if (!p || !ask(rt[p], 1, n, l + i, r)) break;
      }
    }
    int i = (int)t.size();
    while (~i && nxt[i] == -1) i--;
    if (i == -1)
      cout << -1 << '\n';
    else {
      for (int j = 0; j < i; j++) cout << t[j];
      cout << char(nxt[i] + 'a') << '\n';
    }
  }
  return 0;
}