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 = 200005;
inline int gi() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
  return sum;
}
int n, m;
char s[maxn], t[maxn];
int tot = 1, ch[maxn][26], len[maxn];
int stot, rt[maxn], fa[maxn * 60], sum[maxn * 60], lch[maxn * 60],
    rch[maxn * 60];
int nxt[maxn];
struct edge {
  int to, next;
} e[maxn];
int h[maxn], etot;
inline void add(int u, int v) {
  e[++etot] = (edge){v, h[u]};
  h[u] = etot;
}
void insert(int &s, int l, int r, int p) {
  if (!s) s = ++stot;
  ++sum[s];
  if (l == r) return;
  if (p <= ((l + r) >> 1))
    insert(lch[s], l, ((l + r) >> 1), p);
  else
    insert(rch[s], ((l + r) >> 1) + 1, r, p);
}
int merge(int x, int y) {
  if (!x || !y) return x | y;
  int s = ++stot;
  sum[s] = sum[x] + sum[y];
  lch[s] = merge(lch[x], lch[y]);
  rch[s] = merge(rch[x], rch[y]);
  return s;
}
int query(int s, int l, int r, int ql, int qr) {
  if (!s || (ql <= l && r <= qr)) return sum[s];
  int res = 0;
  if (ql <= ((l + r) >> 1)) res += query(lch[s], l, ((l + r) >> 1), ql, qr);
  if (qr >= ((l + r) >> 1) + 1)
    res += query(rch[s], ((l + r) >> 1) + 1, r, ql, qr);
  return res;
}
void extend(int c, int i) {
  static int root = 1, lst = 1;
  int pre = lst, x = ++tot;
  lst = x;
  len[x] = len[pre] + 1;
  insert(rt[x], 1, n, i);
  while (pre && !ch[pre][c]) ch[pre][c] = x, pre = fa[pre];
  if (!pre)
    fa[x] = root;
  else {
    int k = ch[pre][c];
    if (len[k] == len[pre] + 1)
      fa[x] = k;
    else {
      int y = ++tot;
      memcpy(ch[y], ch[k], sizeof(ch[y]));
      len[y] = len[pre] + 1;
      fa[y] = fa[k];
      fa[k] = fa[x] = y;
      while (ch[pre][c] == k) ch[pre][c] = y, pre = fa[pre];
    }
  }
}
void dfs(int u) {
  for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
    dfs(v), rt[u] = merge(rt[u], rt[v]);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) extend(s[i] - 'a', i);
  for (int i = 2; i <= tot; ++i) add(fa[i], i);
  dfs(1);
  m = gi();
  int l, r, len;
  while (m--) {
    l = gi();
    r = gi();
    scanf("%s", t + 1);
    len = strlen(t + 1);
    int u, i;
    for (i = 1, u = 1;; ++i) {
      nxt[i] = -1;
      for (int j = max(0, t[i] - 'a' + 1); j < 26; ++j)
        if (ch[u][j] && query(rt[ch[u][j]], 1, n, l + i - 1, r)) {
          nxt[i] = j;
          break;
        }
      u = ch[u][t[i] - 'a'];
      if (!u || i == len + 1 || !query(rt[u], 1, n, l + i - 1, r)) break;
    }
    while (i && nxt[i] == -1) --i;
    if (!i)
      puts("-1");
    else {
      for (int j = 1; j < i; ++j) putchar(t[j]);
      putchar(nxt[i] + 'a');
      puts("");
    }
  }
  return 0;
}