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 = 200010;
char a[N], s[N];
int n, sa[2][N], rk[2][N], v[N], h[N], p, q = 1;
void sort(int *sa, int *rk, int *SA, int *RK, int k) {
  for (int i = 1; i <= n; i++) v[rk[sa[i]]] = i;
  for (int i = n; i; i--)
    if (sa[i] > k) SA[v[rk[sa[i] - k]]--] = sa[i] - k;
  for (int i = n - k + 1; i <= n; i++) SA[v[rk[i]]--] = i;
  for (int i = 1; i <= n; i++)
    RK[SA[i]] = RK[SA[i - 1]] + (rk[SA[i]] != rk[SA[i - 1]] ||
                                 rk[SA[i] + k] != rk[SA[i - 1] + k]);
}
void da() {
  for (int i = 1; i <= n; i++) v[a[i]]++;
  for (int i = 1; i <= 256; i++) v[i] += v[i - 1];
  for (int i = 1; i <= n; i++) sa[p][v[a[i]]--] = i;
  for (int i = 1; i <= n; i++)
    rk[p][sa[p][i]] = rk[p][sa[p][i - 1]] + (a[sa[p][i]] != a[sa[p][i - 1]]);
  for (int k = 1; k < n; k <<= 1, swap(p, q))
    sort(sa[p], rk[p], sa[q], rk[q], k);
  for (int i = 1, k = 0; i <= n; i++) {
    int j = sa[p][rk[p][i] - 1];
    while (a[i + k] == a[j + k]) k++;
    h[rk[p][i]] = k;
    if (k) k--;
  }
}
struct T {
  int lc, rc, sum;
} t[N * 22];
int rt[N], cnt;
void modify(int &x, int lx, int l, int r, int a) {
  t[x = ++cnt] = t[lx], t[x].sum++;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (a <= mid)
    modify(t[x].lc, t[lx].lc, l, mid, a);
  else
    modify(t[x].rc, t[lx].rc, mid + 1, r, a);
}
int query(int x, int lx, int l, int r, int a, int b) {
  if (!x) return 0;
  if (a <= l && r <= b) return t[x].sum - t[lx].sum;
  int mid = (l + r) >> 1, ret = 0;
  if (a <= mid) ret += query(t[x].lc, t[lx].lc, l, mid, a, b);
  if (b > mid) ret += query(t[x].rc, t[lx].rc, mid + 1, r, a, b);
  return ret;
}
int main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  da();
  for (int i = 1; i <= n; i++) modify(rt[i], rt[i - 1], 1, n, sa[p][i]);
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int l, r, ns;
    scanf("%d%d%s", &l, &r, s + 1);
    ns = strlen(s + 1);
    int tl = 1, tr = n, ans = 1e9, ansl;
    for (int j = 1; j <= min(ns + 1, r - l + 1); j++) {
      int ll = tl, rr = tr;
      while (ll < rr) {
        int mid = (ll + rr) >> 1;
        if (a[sa[p][mid] + j - 1] >= s[j])
          rr = mid;
        else
          ll = mid + 1;
      }
      tl = ll, rr = tr;
      while (ll < rr) {
        int mid = (ll + rr + 1) >> 1;
        if (a[sa[p][mid] + j - 1] <= s[j])
          ll = mid;
        else
          rr = mid - 1;
      }
      tr = ll;
      if (a[sa[p][tr] + j - 1] > s[j]) tr--;
      if (tr != n) {
        ll = tr + 1, rr = n;
        while (ll < rr) {
          int mid = (ll + rr) >> 1;
          if (query(rt[mid], rt[tr], 1, n, l, r - j + 1))
            rr = mid;
          else
            ll = mid + 1;
        }
        if (ll < ans && query(rt[ll], rt[ll - 1], 1, n, l, r - j + 1))
          ans = ll, ansl = j;
      }
      if (a[sa[p][tl] + j - 1] != s[j]) {
        break;
      }
    }
    if (ans == 1e9)
      printf("-1");
    else
      for (int j = 1; j <= ansl; j++) printf("%c", a[sa[p][ans] + j - 1]);
    printf("\n");
  }
  return 0;
}