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>
int fa[200010], ch[200010][26], len[200010], cnt = 1, las = 1;
int ls[200010 * 40], rs[200010 * 40], ntot, n;
int nxt[200010 << 1], to[200010 << 1], head[200010], rcnt;
int root[200010];
void insert(int &u, int l, int r, int p) {
  if (!u) u = ++ntot;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (p <= mid)
    insert(ls[u], l, mid, p);
  else
    insert(rs[u], mid + 1, r, p);
}
void insert(int c) {
  int p = las, q = las = ++cnt;
  len[q] = len[p] + 1;
  insert(root[q], 1, n, len[q]);
  for (; p && !ch[p][c]; p = fa[p]) ch[p][c] = q;
  if (!p)
    fa[q] = 1;
  else {
    int np = ch[p][c];
    if (len[np] == len[p] + 1)
      fa[q] = np;
    else {
      int nq = ++cnt;
      memcpy(ch[nq], ch[np], sizeof(ch[nq]));
      fa[nq] = fa[np];
      fa[np] = fa[q] = nq;
      len[nq] = len[p] + 1;
      for (; p && ch[p][c] == np; p = fa[p]) ch[p][c] = nq;
    }
  }
}
int answer(int u, int l, int r, int L, int R) {
  if (!u || L > R || l > R || L > r) return false;
  if (L <= l && r <= R) return true;
  int mid = (l + r) >> 1;
  return answer(ls[u], l, mid, L, R) || answer(rs[u], mid + 1, r, L, R);
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  int u = ++ntot;
  ls[u] = merge(ls[x], ls[y]);
  rs[u] = merge(rs[x], rs[y]);
  return u;
}
void add(int u, int v) {
  nxt[++rcnt] = head[u];
  to[rcnt] = v;
  head[u] = rcnt;
}
void dfs(int u) {
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    dfs(v);
    root[u] = merge(root[u], root[v]);
  }
}
char s[200010];
int zy[200010];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) insert(s[i] - 'a');
  for (int i = 2; i <= cnt; i++) add(fa[i], i);
  dfs(1);
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    scanf("%s", s + 1);
    int len = strlen(s + 1), u = 1, p;
    for (p = 1;; p++) {
      zy[p] = -1;
      for (int c = p > len ? 0 : s[p] - 'a' + 1; c < 26; c++) {
        int v = ch[u][c];
        if (v && answer(root[v], 1, n, l + p - 1, r)) {
          zy[p] = c;
          break;
        }
      }
      int v = p > len ? 0 : ch[u][s[p] - 'a'];
      if (!v || p == n + 1 || !answer(root[v], 1, n, l + p - 1, r)) break;
      u = v;
    }
    for (; p && zy[p] == -1; p--)
      ;
    if (!p) {
      puts("-1");
      continue;
    } else {
      for (int j = 1; j < p; j++) putchar(s[j]);
      putchar('a' + zy[p]);
      puts("");
    }
  }
  return 0;
}