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 N = 2e5 + 10;
const int M = N * 64;
int la, id, lnk[N], len[N], edp[N], ch[N][26], w[N];
vector<int> G[N];
void init() {
  lnk[0] = -1;
  id = la = 0;
  fill(ch[0], ch[0] + 26, -1);
}
void extend(int c) {
  int u = ++id, p = la;
  fill(ch[u], ch[u] + 26, -1);
  len[u] = len[la] + 1;
  for (; ~p && ch[p][c] == -1; p = lnk[p]) ch[p][c] = u;
  if (p == -1)
    lnk[u] = 0;
  else {
    int q = ch[p][c];
    if (len[q] == len[p] + 1)
      lnk[u] = q;
    else {
      int q0 = ++id;
      copy(ch[q], ch[q] + 26, ch[q0]);
      len[q0] = len[p] + 1;
      lnk[q0] = lnk[q];
      lnk[u] = lnk[q] = q0;
      for (; ~p && ch[p][c] == q; p = lnk[p]) ch[p][c] = q0;
    }
  }
  la = u;
  w[u] = 1;
  edp[u] = len[u];
}
int rt[N], ls[M], rs[M], sz[M], seg_id;
void insert(int &u, int l, int r, int x) {
  u = ++seg_id;
  sz[u] = 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (x <= mid)
    insert(ls[u], l, mid, x);
  else
    insert(rs[u], mid + 1, r, x);
}
bool query(int u, int l, int r, int ql, int qr) {
  if (l == ql && r == qr) return sz[u] >= 1;
  int mid = (l + r) >> 1;
  if (qr <= mid) return query(ls[u], l, mid, ql, qr);
  if (ql > mid) return query(rs[u], mid + 1, r, ql, qr);
  return query(ls[u], l, mid, ql, mid) || query(rs[u], mid + 1, r, mid + 1, qr);
}
int smerge(int u, int v) {
  if (!u && !v) return 0;
  int x = ++seg_id;
  if (!u || !v) {
    u |= v;
    sz[x] = sz[u];
    ls[x] = ls[u];
    rs[x] = rs[u];
    return x;
  }
  sz[x] = sz[u] + sz[v];
  ls[x] = smerge(ls[u], ls[v]);
  rs[x] = smerge(rs[u], rs[v]);
  return x;
}
char s[N];
int n;
void dfs(int u) {
  if (w[u]) insert(rt[u], 1, n, edp[u]);
  for (int v : G[u]) {
    dfs(v);
    rt[u] = smerge(rt[u], rt[v]);
  }
}
bool pd(int u, int len, int l, int r) {
  if (r - l + 1 < len) return 0;
  return query(rt[u], 1, n, l + len - 1, r);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  init();
  for (int i = 1; i <= n; ++i) extend(s[i] - 'a');
  for (int i = 1; i <= id; ++i) G[lnk[i]].push_back(i);
  dfs(0);
  int q;
  scanf("%d", &q);
  while (q--) {
    static char t[N];
    static int pos[N];
    int l, r;
    scanf("%d%d%s", &l, &r, t + 1);
    int m = strlen(t + 1), u = 0, k;
    pos[0] = 0;
    for (k = 1; k <= m; k++) {
      if (!~ch[u][t[k] - 'a']) break;
      pos[k] = u = ch[u][t[k] - 'a'];
    }
    k--;
    bool ok = 0;
    for (; k >= 0 && !ok; k--) {
      for (int c = t[k + 1] ? t[k + 1] - 'a' + 1 : 0; c < 26; c++) {
        if (~ch[pos[k]][c] && pd(ch[pos[k]][c], k + 1, l, r)) {
          t[k + 1] = 'a' + c;
          t[k + 2] = 0;
          puts(t + 1);
          ok = 1;
          break;
        }
      }
    }
    if (!ok) puts("-1");
  }
  return 0;
}