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 = 200500;
vector<int> g[maxn];
char s[maxn];
int fa[maxn], len[maxn], go[maxn][30], rt[maxn];
int w[maxn * 20], lc[maxn * 20], rc[maxn * 20];
int n, tot, last, idx, q;
void add(int c) {
  int p, np, q, nq;
  p = last;
  last = np = ++tot;
  len[np] = len[p] + 1;
  for (; p && !go[p][c]; p = fa[p]) go[p][c] = np;
  if (!p)
    fa[np] = 1;
  else {
    q = go[p][c];
    if (len[q] == len[p] + 1) {
      fa[np] = q;
      return;
    } else {
      nq = ++tot;
      len[nq] = len[p] + 1;
      for (int i = 0; i <= 25; i++) go[nq][i] = go[q][i];
      fa[nq] = fa[q];
      fa[q] = fa[np] = nq;
      for (; p && go[p][c] == q; p = fa[p]) go[p][c] = nq;
    }
  }
}
void ins(int &i, int l, int r, int pos) {
  if (!i) i = ++idx;
  if (l == r) {
    w[i] = 1;
    return;
  }
  int mid = (l + r) / 2;
  if (pos <= mid)
    ins(lc[i], l, mid, pos);
  else
    ins(rc[i], mid + 1, r, pos);
  w[i] = w[lc[i]] | w[rc[i]];
}
int merge(int x, int y, int l, int r) {
  if (!x || !y) return x + y;
  int z = ++idx, mid = (l + r) / 2;
  if (l == r)
    w[z] = w[x] | w[y];
  else {
    lc[z] = merge(lc[x], lc[y], l, mid);
    rc[z] = merge(rc[x], rc[y], mid + 1, r);
    w[z] = w[lc[z]] | w[rc[z]];
  }
  return z;
}
int ask(int i, int l, int r, int L, int R) {
  if (L <= l && r <= R) return w[i];
  int mid = (l + r) / 2, ans = 0;
  if (L <= mid) ans |= ask(lc[i], l, mid, L, R);
  if (R > mid) ans |= ask(rc[i], mid + 1, r, L, R);
  return ans;
}
void dfs(int u) {
  for (auto v : g[u]) {
    dfs(v);
    rt[u] = merge(rt[u], rt[v], 1, n);
  }
}
int main() {
  scanf("%s", s + 1);
  last = tot = 1;
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) add(s[i] - 'a'), ins(rt[last], 1, n, i);
  for (int i = 1; i <= tot; i++) g[fa[i]].push_back(i);
  dfs(1);
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    scanf("%s", s + 1);
    int now = 1, len = strlen(s + 1), pos = 0;
    char res = 0;
    for (int i = 1; i <= len + 1; i++) {
      int c = i > len ? 0 : (s[i] - 'a' + 1);
      for (int j = c; j <= 25; j++) {
        int x = go[now][j];
        if (ask(rt[x], 1, n, l + i - 1, r)) {
          res = 'a' + j;
          pos = i - 1;
          break;
        }
      }
      if (c && go[now][c - 1])
        now = go[now][c - 1];
      else
        break;
    }
    if (!res)
      puts("-1");
    else {
      for (int i = 1; i <= pos; i++) putchar(s[i]);
      putchar(res);
      puts("");
    }
  }
  return 0;
}