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;
const int maxn = 2e5 + 42;
string s;
int link[maxn], len[maxn], alflalfa[maxn];
map<char, int> to[maxn];
int sz = 1, last;
void add_letter(char c) {
  int p = last;
  last = sz++;
  len[last] = alflalfa[last] = len[p] + 1;
  for (; to[p][c] == 0; p = link[p]) {
    to[p][c] = last;
  }
  if (to[p][c] == last) {
    return;
  }
  int q = to[p][c];
  if (len[q] == len[p] + 1) {
    link[last] = q;
    return;
  }
  int cl = sz++;
  to[cl] = to[q];
  alflalfa[cl] = alflalfa[q];
  link[cl] = link[q];
  len[cl] = len[p] + 1;
  link[last] = link[q] = cl;
  for (; to[p][c] == q; p = link[p]) {
    to[p][c] = cl;
  }
}
vector<int> g[maxn];
int in[maxn], out[maxn];
map<char, int> rto[maxn];
int t;
void dfs(int v = 0) {
  in[v] = t++;
  for (auto u : g[v]) {
    rto[v][s[alflalfa[u] - len[v] - 1]] = u;
  }
  for (auto it : rto[v]) {
    dfs(it.second);
  }
  out[v] = t;
}
int mx[4 * maxn];
void upd(int p, int c, int v = 1, int l = 0, int r = maxn) {
  mx[v] = c;
  if (r - l > 1) {
    int m = (l + r) / 2;
    if (p < m) {
      upd(p, c, 2 * v, l, m);
    } else {
      upd(p, c, 2 * v + 1, m, r);
    }
  }
}
int get(int a, int b, int v = 1, int l = 0, int r = maxn) {
  if (a <= l && r <= b) {
    return mx[v];
  } else if (r <= a || b <= l) {
    return 0;
  } else {
    int m = (l + r) / 2;
    return max(get(a, b, 2 * v, l, m), get(a, b, 2 * v + 1, m, r));
  }
}
int used[maxn];
int n, m;
string get_str() {
  string s;
  for (int i = 0; i < 10; i++) {
    s += 'a' + (rand() % 2);
  }
  cin >> s;
  n = s.size();
  return s;
}
int get_m() {
  int m = 100;
  cin >> m;
  return m;
}
void get(int &l, int &r, string &t) {
  l = rand() % n + 1;
  r = rand() % n + 1;
  if (l > r) {
    swap(l, r);
  }
  for (int i = 0; i < 4; i++) {
    t += 'a' + (rand() % 2);
  }
  cin >> l >> r >> t;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int seed = 1535904772;
  srand(seed);
  s = get_str();
  n = s.size();
  reverse(begin(s), end(s));
  for (auto c : s) {
    add_letter(c);
  }
  for (int i = 1; i < sz; i++) {
    g[link[i]].push_back(i);
  }
  dfs();
  m = get_m();
  vector<int> l(m), r(m);
  string ans[m];
  string qq[m];
  vector<int> que[n];
  for (int i = 0; i < m; i++) {
    get(l[i], r[i], qq[i]);
    que[l[i] - 1].push_back(i);
  }
  int v = 0;
  for (int i = 1; i <= n; i++) {
    v = to[v][s[i - 1]];
    upd(in[v], i);
    for (auto it : que[n - i]) {
      int go_to = 0;
      int ln = 0;
      int best_ln = 0;
      int best_v = 0;
      auto ok = [&](int v, int ln) {
        int first_l = n - get(in[v], out[v]);
        return first_l + ln <= r[it];
      };
      qq[it] += "#";
      for (auto c : qq[it]) {
        ln++;
        if (ln == len[go_to] + 1) {
          for (auto it : rto[go_to]) {
            char nc = it.first;
            int n_goto = it.second;
            if (nc > c && ok(n_goto, ln)) {
              best_ln = ln;
              best_v = n_goto;
              break;
            }
          }
          if (!rto[go_to].count(c)) {
            break;
          } else {
            go_to = rto[go_to][c];
          }
        } else {
          char true_c = s[alflalfa[go_to] - ln];
          if (true_c == c) {
            if (ok(go_to, ln)) {
              continue;
            } else {
              break;
            }
          } else {
            if (true_c > c && ok(go_to, ln)) {
              best_ln = ln;
              best_v = go_to;
            }
            break;
          }
        }
      }
      if (best_ln == 0) {
        ans[it] = "1-";
      } else {
        ans[it] = s.substr(alflalfa[best_v] - best_ln, best_ln);
      }
    }
  }
  for (auto it : ans) {
    reverse(begin(it), end(it));
    cout << it << "\n";
  }
  return 0;
}