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;
int trans[210000][31], root[210000], maxlen[210000], fail[210000];
int last, cnt, tot;
int pos[210000];
char st[210000], s[210000];
int b[210000], c[210000];
int tree[6100000], lson[6100000], rson[6100000];
int dx, dy, lens, n, m, l, r;
void extend(int x, int id) {
  int p = last, np = ++tot;
  last = np;
  maxlen[np] = id;
  pos[id] = np;
  while (p && !trans[p][x]) trans[p][x] = np, p = fail[p];
  if (!p)
    fail[np] = 1;
  else {
    int q = trans[p][x];
    if (maxlen[q] == maxlen[p] + 1)
      fail[np] = q;
    else {
      int nq = ++tot;
      maxlen[nq] = maxlen[p] + 1;
      memcpy(trans[nq], trans[q], sizeof(trans[q]));
      fail[nq] = fail[q], fail[q] = fail[np] = nq;
      while (p && trans[p][x] == q) trans[p][x] = nq, p = fail[p];
    }
  }
}
void add(int &rex, int l, int r, int x) {
  if (!rex) rex = ++cnt;
  if (l == r) {
    tree[rex] = 1;
    return;
  }
  int mid = l + r >> 1;
  if (x <= mid)
    add(lson[rex], l, mid, x);
  else
    add(rson[rex], mid + 1, r, x);
  tree[rex] = tree[lson[rex]] | tree[rson[rex]];
}
int merge(int x, int y) {
  if (!x && !y) return 0;
  if (!x) return y;
  if (!y) return x;
  int t = ++cnt;
  lson[t] = merge(lson[x], lson[y]);
  rson[t] = merge(rson[x], rson[y]);
  tree[t] = tree[lson[t]] | tree[rson[t]];
  return t;
}
void build() {
  for (int i = 1; i <= tot; i++) b[maxlen[i]]++;
  for (int i = 1; i <= tot; i++) b[i] += b[i - 1];
  for (int i = tot; i; i--) c[b[maxlen[i]]--] = i;
  for (int i = 1; i <= n; i++) add(root[pos[i]], 1, n, i);
  for (int i = tot; i > 1; i--)
    root[fail[c[i]]] = merge(root[fail[c[i]]], root[c[i]]);
}
int query(int rex, int l, int r, int x, int y) {
  if (!rex) return 0;
  if (l == x && r == y) return tree[rex];
  int mid = l + r >> 1;
  if (y <= mid)
    return query(lson[rex], l, mid, x, y);
  else if (x > mid)
    return query(rson[rex], mid + 1, r, x, y);
  else
    return query(lson[rex], l, mid, x, mid) |
           query(rson[rex], mid + 1, r, mid + 1, y);
}
int main() {
  last = 1, tot = 1;
  scanf("%s", st + 1);
  n = strlen(st + 1);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) extend(st[i] - 'a', i);
  build();
  while (m--) {
    scanf("%d%d%s", &l, &r, s + 1);
    lens = strlen(s + 1);
    int now = 1, flag = 0;
    dx = 0, dy = 0;
    for (int i = 1; i <= lens + 1; i++) {
      for (int j = i == lens + 1 ? 0 : s[i] - 'a' + 1; j < 26; j++) {
        if (trans[now][j]) {
          if (!query(root[trans[now][j]], 1, n, l + i - 1, r)) continue;
          flag = 1;
          dx = i, dy = j;
          break;
        }
      }
      if (i == lens + 1) break;
      if (!trans[now][s[i] - 'a']) break;
      now = trans[now][s[i] - 'a'];
    }
    if (flag) {
      for (int i = 1; i < dx; i++) printf("%c", s[i]);
      printf("%c\n", dy + 'a');
    } else
      printf("-1\n");
  }
}