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 = 200005;
const int M = 10000005;
int ch[N][26], nd, la, n;
int l[N], fa[N], id[N];
vector<int> e[N];
char s[N];
void extend(int c, int id) {
  ::id[la] = id;
  int p = la, np = ++nd;
  l[np] = l[p] + 1;
  for (; p && !ch[p][c]; p = fa[p]) ch[p][c] = np;
  if (!p)
    fa[np] = 1;
  else {
    int q = ch[p][c];
    if (l[q] == l[p] + 1)
      fa[np] = q;
    else {
      int nq = ++nd;
      l[nq] = l[p] + 1;
      memcpy(ch[nq], ch[q], sizeof(ch[q]));
      fa[nq] = fa[q];
      fa[q] = fa[np] = nq;
      for (; p && ch[p][c] == q; p = fa[p]) ch[p][c] = nq;
    }
  }
  la = np;
}
int ls[M], rs[M], S[M];
int rt[N], ndd;
void insert(int &k, int l, int r, int p) {
  if (!k) k = ++ndd;
  S[k] |= 1 << (s[p] - 'a');
  if (l == r) return;
  int mid = (l + r) / 2;
  if (p <= mid)
    insert(ls[k], l, mid, p);
  else
    insert(rs[k], mid + 1, r, p);
}
int merge(int x, int y) {
  if (!x || !y) return x | y;
  int k = ++ndd;
  S[k] = S[x] | S[y];
  ls[k] = merge(ls[x], ls[y]);
  rs[k] = merge(rs[x], rs[y]);
  return k;
}
int ask(int k, int l, int r, int x, int y) {
  if (!k) return 0;
  if (l == x && r == y) return S[k];
  int mid = (l + r) / 2;
  if (y <= mid) return ask(ls[k], l, mid, x, y);
  if (x > mid) return ask(rs[k], mid + 1, r, x, y);
  return ask(ls[k], l, mid, x, mid) | ask(rs[k], mid + 1, r, mid + 1, y);
}
void dfs(int x) {
  if (id[x]) insert(rt[x], 1, n, id[x]);
  for (auto i : e[x]) dfs(i), rt[x] = merge(rt[x], rt[i]);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  nd = la = 1;
  for (int i = (int)(1); i <= (int)(n); i++) extend(s[i] - 'a', i);
  for (int i = (int)(2); i <= (int)(nd); i++) e[fa[i]].push_back(i);
  dfs(1);
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int l, r;
    scanf("%d%d%s", &l, &r, s + 1);
    int m = strlen(s + 1);
    s[++m] = 'a' - 1;
    int p1 = -1, p2 = -1, x = 1;
    for (int i = (int)(1); i <= (int)(min(m, r - l + 1)); i++) {
      int st = ask(rt[x], 1, n, l + i - 1, r);
      for (int j = (int)(25); j >= (int)(s[i] - 'a' + 1); j--)
        if (st & (1 << j)) p1 = i, p2 = j;
      if (!(x = ch[x][s[i] - 'a'])) break;
    }
    if (p1 == -1)
      puts("-1");
    else {
      s[p1] = p2 + 'a', s[p1 + 1] = 0;
      printf("%s\n", s + 1);
    }
  }
}