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 = 200005, maxt = 2200005;
int ls[maxt], rs[maxt], sum[maxt], rt[maxn], tot, n, Q;
char A[maxn], B[maxn];
int rnk[maxn], sa[maxn], fst[maxn], sec[maxn], cnt[maxn];
int cmp(int a, int b, int i) {
  if (a + i * 2 > n || b + i * 2 > n) return 1;
  return sec[a] != sec[b] || sec[a + i] != sec[b + i];
}
void init_sa() {
  for (int i = 0; i < n; i++) ++cnt[fst[i] = A[i]];
  int m = 128;
  for (int i = 1; i < m; i++) cnt[i] += cnt[i - 1];
  for (int i = n - 1; i >= 0; i--) sa[--cnt[fst[i]]] = i;
  for (int i = 1; i < n; i <<= 1) {
    int p = 0;
    for (int j = n - i; j < n; j++) sec[p++] = j;
    for (int j = 0; j < n; j++)
      if (sa[j] >= i) sec[p++] = sa[j] - i;
    memset(cnt, 0, sizeof(cnt));
    for (int j = 0; j < n; j++) ++cnt[fst[sec[j]]];
    for (int j = 1; j < m; j++) cnt[j] += cnt[j - 1];
    for (int j = n - 1; j >= 0; j--) sa[--cnt[fst[sec[j]]]] = sec[j];
    memcpy(sec, fst, sizeof(sec));
    fst[sa[0]] = p = 0;
    for (int j = 1; j < n; j++) fst[sa[j]] = (p += cmp(sa[j - 1], sa[j], i));
    m = p + 1;
  }
  for (int i = n; i > 0; i--) sa[i] = sa[i - 1];
  sa[0] = n;
  for (int i = 0; i <= n; i++) rnk[sa[i]] = i;
}
int lower(int l, int r, int k) {
  for (--l; l + 1 < r;) {
    int mid = (l + r) >> 1;
    if (A[sa[mid] + k] >= B[k])
      r = mid;
    else
      l = mid;
  }
  return r;
}
int upper(int l, int r, int k) {
  for (++r; l + 1 < r;) {
    int mid = (l + r) >> 1;
    if (A[sa[mid] + k] > B[k])
      r = mid;
    else
      l = mid;
  }
  return A[sa[l] + k] > B[k] ? l : r;
}
int build(int l = 1, int r = n) {
  int p = ++tot;
  if (l == r) return p;
  int mid = (l + r) >> 1;
  ls[p] = build(l, mid);
  rs[p] = build(mid + 1, r);
  return p;
}
int update(int pre, int x, int l = 1, int r = n) {
  int p = ++tot;
  sum[p] = sum[pre] + 1;
  if (l == r) return p;
  int mid = (l + r) >> 1;
  if (x <= mid)
    ls[p] = update(ls[pre], x, l, mid), rs[p] = rs[pre];
  else
    rs[p] = update(rs[pre], x, mid + 1, r), ls[p] = ls[pre];
  return p;
}
pair<int, int> query(int a, int b, int x, int l = 1, int r = n) {
  if (x > r) return pair<int, int>(-1, 0);
  int mid = (l + r) >> 1;
  if (x <= l) {
    if (sum[b] - sum[a] == 0) return pair<int, int>(-1, 0);
    if (l == r) return pair<int, int>(l, 1);
    if (sum[ls[b]] - sum[ls[a]] > 0)
      return query(ls[a], ls[b], x, l, mid);
    else
      return query(rs[a], rs[b], x, mid + 1, r);
  }
  pair<int, int> p = query(ls[a], ls[b], x, l, mid);
  if (p.second > 0) return p;
  return query(rs[a], rs[b], x, mid + 1, r);
}
int main() {
  scanf("%s%d", A, &Q);
  n = strlen(A);
  init_sa();
  rt[n] = build();
  for (int i = 0; i < n; i++) rt[i] = update(rt[(i + n) % (n + 1)], rnk[i]);
  while (Q--) {
    int a, b;
    scanf("%d%d%s", &a, &b, B), --a, --b;
    int len = strlen(B);
    B[len] = 'a' - 1, B[len + 1] = 0;
    int l = 1, r = n;
    pair<int, int> res = pair<int, int>(INT_MAX, INT_MAX);
    for (int i = 0; i <= len && i <= b - a && l <= r; i++) {
      int nl = lower(l, r, i), nr = upper(l, r, i);
      if (A[sa[nl] + i] < B[i]) break;
      pair<int, int> p = query(rt[(a + n) % (n + 1)], rt[b - i], nr);
      if (p.second > 0) res = min(res, pair<int, int>(p.first, i));
      l = nl, r = nr - 1;
    }
    if (res.first == INT_MAX)
      putchar('-'), putchar('1');
    else
      for (int i = sa[res.first]; i <= sa[res.first] + res.second; i++)
        putchar(A[i]);
    putchar('\n');
  }
  return 0;
}