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;
inline int read() {
  int f = 1, ans = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + c - '0';
    c = getchar();
  }
  return f * ans;
}
const int MAXN = 4e5 + 11;
vector<int> vec[MAXN];
int ch[MAXN][27], las = 1, tot = 1, TT = 0, N, Q, len[MAXN], fa[MAXN], rt[MAXN],
                  all;
char S[MAXN];
struct Segment {
  int ls[MAXN * 34], rs[MAXN * 34];
  void Modify(int &k, int l, int r, int ps) {
    if (!k) k = ++TT;
    if (l == r) return;
    int mid = (l + r) >> 1;
    if (ps <= mid) Modify(ls[k], l, mid, ps);
    if (mid < ps) Modify(rs[k], mid + 1, r, ps);
    return;
  }
  void print(int k, int l, int r) {
    if (!k) return;
    if (l == r) {
      printf("%d ", l);
      return;
    }
    int mid = (l + r) >> 1;
    print(ls[k], l, mid), print(rs[k], mid + 1, r);
  }
  int merge(int p, int q) {
    if (!p || !q) return p + q;
    int u = (++TT);
    ls[u] = merge(ls[p], ls[q]), rs[u] = merge(rs[p], rs[q]);
    return u;
  }
  bool Query(int k, int l, int r, int x, int y) {
    if (!k) return 0;
    if (x <= l && r <= y) return 1;
    int mid = (l + r) >> 1;
    bool res = 0;
    if (x <= mid) res |= Query(ls[k], l, mid, x, y);
    if (mid < y) res |= Query(rs[k], mid + 1, r, x, y);
    return res;
  }
  void debug(int k) {
    print(rt[k], 1, N);
    printf("\n");
    return;
  }
} T;
void ins(int c) {
  int p = las, np = las = ++tot;
  len[np] = len[p] + 1;
  T.Modify(rt[np], 1, N, len[np]);
  for (; p && !ch[p][c]; p = fa[p]) ch[p][c] = np;
  if (!p) {
    fa[np] = 1;
    return;
  }
  int q = ch[p][c];
  if (len[p] + 1 == len[q]) {
    fa[np] = q;
    return;
  }
  int nq = ++tot;
  len[nq] = len[p] + 1, fa[nq] = fa[q];
  for (int i = 0; i < 27; i++) ch[nq][i] = ch[q][i];
  fa[q] = fa[np] = nq;
  for (; p && ch[p][c] == q; p = fa[p]) ch[p][c] = nq;
  return;
}
void dfs(int u) {
  for (auto v : vec[u]) dfs(v), rt[u] = T.merge(rt[u], rt[v]);
}
int L, R, LEN;
char Ans[MAXN];
bool ff = 1;
void calc(int now, int len, bool f) {
  if (!f) {
    for (int i = 1; i < len; i++) printf("%c", Ans[i]);
    printf("\n");
    ff = 0;
    return;
  }
  int be;
  if (!f || len > LEN)
    be = 0;
  else
    be = S[len] - 'a';
  for (int i = be; i < 26; i++) {
    int u = ch[now][i];
    if (!u) continue;
    if (!T.Query(rt[u], 1, N, L + len - 1, R)) continue;
    Ans[len] = i + 'a';
    calc(u, len + 1, f & (i == (S[len] - 'a')));
    if (!ff) return;
  }
}
int main() {
  scanf("%s", S + 1);
  N = strlen(S + 1);
  Q = read();
  for (int i = 1; i <= N; i++) ins(S[i] - 'a');
  for (int i = 2; i <= tot; i++) vec[fa[i]].push_back(i);
  dfs(1);
  while (Q--) {
    L = read(), R = read();
    scanf("%s", S + 1);
    LEN = strlen(S + 1);
    ff = 1;
    calc(1, 1, 1);
    if (ff) printf("-1\n");
  }
}