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;
namespace IO {
template <typename T>
inline void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
  return;
}
template <typename T>
inline void write(T x = 0) {
  T wr[51];
  wr[0] = 0;
  if (x < 0) putchar('-'), x = -x;
  if (!x) putchar(48);
  while (x) wr[++wr[0]] = x % 10, x /= 10;
  while (wr[0]) putchar(48 + wr[wr[0]--]);
  return;
}
}  // namespace IO
using IO::read;
using IO::write;
const int N = 4e5 + 11;
int n, T;
char s[N];
int ch[N][27], l[N], fa[N], rt[N], ls[N * 40], rs[N * 40], nxt[N], to[N],
    head[N];
int cnt = 1, las = 1, tot, e;
inline void add(int x, int y) {
  nxt[++e] = head[x];
  head[x] = e;
  to[e] = y;
}
inline void insert(int &k, int p, int l = 1, int r = n) {
  k = ++tot;
  if (l == r) return;
  int mid = (l + r) >> 1;
  p <= mid ? insert(ls[k], p, l, mid) : insert(rs[k], p, mid + 1, r);
}
inline int merge(int x, int y) {
  if (!x || !y) return x | y;
  int z = ++tot;
  ls[z] = merge(ls[x], ls[y]);
  rs[z] = merge(rs[x], rs[y]);
  return z;
}
inline int query(int x, int y, int k, int l = 1, int r = n) {
  if (!k || x > y) return 0;
  if (x <= l && r <= y) return 1;
  int mid = (l + r) >> 1, ans = 0;
  if (x <= mid) ans = query(x, y, ls[k], l, mid);
  if (ans) return 1;
  if (mid < y) ans |= query(x, y, rs[k], mid + 1, r);
  return ans;
}
inline void extend(int i, int c) {
  int np = ++cnt, p = las;
  las = np;
  l[np] = l[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 (l[q] == l[p] + 1)
      fa[np] = q;
    else {
      int nq = ++cnt;
      l[nq] = l[p] + 1;
      memcpy(ch[nq], ch[q], sizeof ch[q]);
      fa[nq] = fa[q], fa[q] = fa[np] = nq;
      for (; p && ch[p][c] == q; p = fa[p]) ch[p][c] = nq;
    }
  }
  insert(rt[np], i);
}
inline void dfs(int x) {
  for (register int e = head[x]; e; e = nxt[e])
    dfs(to[e]), rt[x] = merge(rt[x], rt[to[e]]);
}
int main() {
  gets(s + 1);
  n = strlen(s + 1);
  for (register int i = 1; i <= n; ++i) extend(i, s[i] - 'a');
  for (register int i = 2; i <= cnt; ++i) add(fa[i], i);
  dfs(1);
  read(T);
  char ans;
  for (int l, r, c, now, len, n; T--;) {
    read(l), read(r);
    scanf("%s", s + 1);
    n = strlen(s + 1);
    now = 1, ans = 0;
    for (register int i = 1; i <= n + 1; ++i) {
      c = s[i] - 'a';
      if (i == n + 1) c = -1;
      for (register int j = c + 1; j <= 25; ++j)
        if (ch[now][j]) {
          if (query(l + i - 1, r, rt[ch[now][j]])) {
            len = i - 1, ans = j + 'a';
            break;
          }
        }
      if (c != -1 && ch[now][c])
        now = ch[now][c];
      else
        break;
    }
    if (!ans) {
      puts("-1");
      continue;
    }
    for (register int i = 1; i <= len; ++i) putchar(s[i]);
    putchar(ans);
    putchar('\n');
  }
  return 0;
}