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 N = 2e5 + 10;
int n, m, q, tot, last, rt[N], cnt;
char s[N], ans[N];
vector<int> e[N];
struct Node {
  int fa, len, tr[26];
} a[N << 1];
namespace Seg {
int tot;
struct Tree {
  int lc, rc, val;
} t[N << 5];
void up_(int o) { t[o].val = t[t[o].lc].val + t[t[o].rc].val; }
int merge_(int u, int v, int l, int r) {
  if (!u || !v) return u + v;
  int x = ++tot;
  if (l == r) {
    t[x].val = t[u].val + t[v].val;
    return x;
  }
  int mid = (l + r) >> 1;
  t[x].lc = merge_(t[u].lc, t[v].lc, l, mid);
  t[x].rc = merge_(t[u].rc, t[v].rc, mid + 1, r);
  return up_(x), x;
}
void ins_(int &o, int l, int r, int x) {
  if (!o) o = ++tot;
  if (l == r) {
    t[o].val = 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    ins_(t[o].lc, l, mid, x);
  else
    ins_(t[o].rc, mid + 1, r, x);
  up_(o);
}
bool ask_(int o, int l, int r, int x, int y) {
  if (!o) return 0;
  if (x <= l && r <= y) return t[o].val;
  int mid = (l + r) >> 1;
  if (x <= mid && ask_(t[o].lc, l, mid, x, y)) return 1;
  if (mid < y && ask_(t[o].rc, mid + 1, r, x, y)) return 1;
  return 0;
}
}  // namespace Seg
void extend_(int k, int id) {
  int x = ++tot, p = last;
  a[x].len = a[p].len + 1;
  while (p && !a[p].tr[k]) a[p].tr[k] = x, p = a[p].fa;
  if (!p)
    a[x].fa = 1;
  else {
    int q = a[p].tr[k];
    if (a[p].len + 1 == a[q].len)
      a[x].fa = q;
    else {
      a[++tot] = a[q], a[tot].len = a[p].len + 1;
      a[q].fa = a[x].fa = tot;
      while (p && a[p].tr[k] == q) a[p].tr[k] = tot, p = a[p].fa;
    }
  }
  last = x, Seg ::ins_(rt[x], 1, n, id);
}
void dfs_(int u) {
  for (int v, i = 0; i < (int)e[u].size(); i++)
    v = e[u][i], dfs_(v), rt[u] = Seg ::merge_(rt[u], rt[v], 1, n);
}
bool solve_(int k, int u, int l, int r) {
  int v;
  if (k > m) {
    for (int i = 0; i < 26; i++)
      if (a[u].tr[i]) {
        v = a[u].tr[i], ans[++cnt] = ('a' + i);
        if (Seg ::ask_(rt[v], 1, n, l + k - 1, r)) {
          for (int j = 1; j <= cnt; j++) printf("%c", ans[j]);
          puts("");
          return 1;
        }
        cnt--;
      }
    return 0;
  }
  if (a[u].tr[s[k] - 'a']) {
    v = a[u].tr[s[k] - 'a'];
    if (Seg ::ask_(rt[v], 1, n, l + k - 1, r)) {
      ans[++cnt] = s[k];
      if (solve_(k + 1, v, l, r)) return 1;
      cnt--;
    }
  }
  for (int i = 0; i < 26; i++)
    if (i > s[k] - 'a' && a[u].tr[i]) {
      v = a[u].tr[i], ans[++cnt] = 'a' + i;
      if (Seg ::ask_(rt[v], 1, n, l + k - 1, r)) {
        for (int j = 1; j <= cnt; j++) printf("%c", ans[j]);
        puts("");
        return 1;
      }
      --cnt;
    }
  return 0;
}
int main() {
  scanf("%s%d", s + 1, &q);
  n = strlen(s + 1), last = tot = 1;
  for (int i = 1; i <= n; i++) extend_(s[i] - 'a', i);
  for (int i = 2; i <= tot; i++) e[a[i].fa].push_back(i);
  dfs_(1);
  for (int l, r, i = 1; i <= q; i++) {
    scanf("%d%d%s", &l, &r, s + 1);
    m = strlen(s + 1), cnt = 0;
    if (!solve_(1, 1, l, r)) puts("-1");
  }
}