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 inf = 1e9;
const long long Inf = 1e18;
const int N = 2e5 + 10;
const int mod = 0;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
};
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
};
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }
void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }
char s[N], t[N];
int n, ch[N][26], fa[N], len[N], tot = 1, last = 1;
void extend(int c) {
  int p = last, np = ++tot;
  last = np;
  len[np] = len[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 (len[p] + 1 == len[q])
      fa[np] = q;
    else {
      int nq = ++tot;
      len[nq] = len[p] + 1;
      memcpy(ch[nq], ch[q], sizeof(ch[q]));
      fa[nq] = fa[q];
      fa[q] = fa[np] = nq;
      for (; ch[p][c] == q; p = fa[p]) ch[p][c] = nq;
    }
  }
}
int node = 0, ls[N * 50], rs[N * 50], rt[N];
void build(int &o, int l, int r, int p) {
  o = ++node;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (p <= mid)
    build(ls[o], l, mid, p);
  else
    build(rs[o], mid + 1, r, p);
}
bool query(int o, int l, int r, int L, int R) {
  if (!o) return 0;
  if (L <= l && r <= R) return 1;
  int mid = (l + r) >> 1;
  if (L <= mid && query(ls[o], l, mid, L, R)) return 1;
  if (R > mid && query(rs[o], mid + 1, r, L, R)) return 1;
  return 0;
}
int merge(int a, int b) {
  if (!a || !b) return a | b;
  int o = ++node;
  ls[o] = merge(ls[a], ls[b]);
  rs[o] = merge(rs[a], rs[b]);
  return o;
}
vector<int> E[N];
void dfs(int u) {
  for (int v : E[u]) dfs(v), rt[u] = merge(rt[u], rt[v]);
}
int ans[N];
bool query(int x, int o, int l, int r) {
  for (int i = max(0, t[x] - 'a'); i < 26; i++)
    if (x <= r - l + 1 && ch[o][i] && query(rt[ch[o][i]], 1, n, l + x - 1, r)) {
      ans[x] = i;
      if (i > t[x] - 'a') {
        for (int j = 1; j <= x; j++) putchar(ans[j] + 'a');
        puts("");
        return 1;
      } else if (query(x + 1, ch[o][i], l, r))
        return 1;
    }
  return 0;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) extend(s[i] - 'a'), build(rt[last], 1, n, i);
  for (int i = 2; i <= tot; i++) E[fa[i]].push_back(i);
  dfs(1);
  int q = gi();
  while (q--) {
    int l = gi(), r = gi();
    scanf("%s", t + 1);
    int m = strlen(t + 1);
    t[m + 1] = '#';
    if (!query(1, 1, l, r)) puts("-1");
  }
  return 0;
}