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 std::cerr;
using std::endl;
const int N = 2e5 + 233;
char S[N], T[N];
int n, m, Q;
int fa[N * 2], ch[N * 2][26], len[N * 2], last = 1, tot = 1, end[N];
inline void insert(int c, int id) {
  int p = last, np = ++tot;
  len[last = np] = len[p] + 1;
  end[id] = np;
  while (p && !ch[p][c]) ch[p][c] = np, p = fa[p];
  if (!p)
    fa[np] = 1;
  else {
    int q = ch[p][c];
    if (len[q] == len[p] + 1)
      fa[np] = q;
    else {
      int nq = ++tot;
      memcpy(ch[nq], ch[q], sizeof(ch[q]));
      len[nq] = len[p] + 1;
      fa[nq] = fa[q];
      fa[q] = fa[np] = nq;
      while (p && ch[p][c] == q) ch[p][c] = nq, p = fa[p];
    }
  }
}
int ls[N * 50], rs[N * 50], size[N * 50], num, root[N * 2];
void insert(int &p, int x, int L, int R) {
  p = ++num, size[p] = 1;
  if (L == R) return;
  int mid = (L + R) >> 1;
  if (x <= mid)
    insert(ls[p], x, L, mid);
  else
    insert(rs[p], x, mid + 1, R);
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  int p = ++num;
  ls[p] = merge(ls[x], ls[y]);
  rs[p] = merge(rs[x], rs[y]);
  size[p] = size[x] + size[y];
  return p;
}
int query(int p, int l, int r, int L, int R) {
  if (!p) return 0;
  if (l <= L && r >= R) return size[p];
  int mid = (L + R) >> 1, ret = 0;
  if (l <= mid) ret += query(ls[p], l, r, L, mid);
  if (r > mid) ret += query(rs[p], l, r, mid + 1, R);
  return ret;
}
inline void build() {
  static int buc[N], A[N];
  for (int i = 1; i <= tot; ++i) ++buc[len[i]];
  for (int i = 1; i <= tot; ++i) buc[i] += buc[i - 1];
  for (int i = tot; i >= 1; --i) A[buc[len[i]]--] = i;
  for (int i = 1; i <= n; ++i) insert(root[end[i]], i, 1, n);
  for (int i = tot; i > 1; --i) {
    int x = A[i];
    root[fa[x]] = merge(root[fa[x]], root[x]);
  }
}
int stk[N], top;
inline void query(int l, int r) {
  top = 0;
  int now = 1;
  stk[++top] = now;
  for (int i = 1; i <= m; ++i) {
    int c = T[i] - 'a';
    if (!ch[now][c]) break;
    if (!query(root[ch[now][c]], l + i - 1, r, 1, n)) break;
    now = ch[now][c];
    stk[++top] = now;
  }
  for (int i = top; i; --i) {
    int st = 0, x = stk[i];
    if (i <= m) st = T[i] - 'a' + 1;
    for (int j = st; j < 26; ++j) {
      if (!ch[x][j]) continue;
      if (!query(root[ch[x][j]], l + i - 1, r, 1, n)) continue;
      for (int k = 1; k < i; ++k) putchar(T[k]);
      putchar('a' + j);
      putchar('\n');
      return;
    }
  }
  puts("-1");
}
int main() {
  scanf("%s", S + 1);
  n = strlen(S + 1);
  for (int i = 1; i <= n; ++i) insert(S[i] - 'a', i);
  build();
  scanf("%d", &Q);
  while (Q--) {
    int l, r;
    scanf("%d %d %s", &l, &r, T + 1);
    m = strlen(T + 1);
    query(l, r);
  }
  return 0;
}