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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  write(a);
  puts("");
}
const int N = 100005, M = 200005, MM = 20000005;
int last = 1, tot = 1, nodecnt, n, dp[M], len[M], go[M][26], pre[M], rig[M],
    rt[M];
vector<int> v[M];
char ch[N];
int lson[MM], rson[MM], tree[MM];
void add(int c) {
  int p = last, np = ++tot;
  last = np;
  len[np] = len[p] + 1;
  for (; !go[p][c] && p; p = pre[p]) go[p][c] = np;
  if (!p)
    pre[np] = 1;
  else {
    int q = go[p][c];
    if (len[q] == len[p] + 1)
      pre[np] = q;
    else {
      int nq = ++tot;
      memcpy(go[nq], go[q], sizeof(go[q]));
      len[nq] = len[p] + 1;
      pre[nq] = pre[q];
      pre[q] = pre[np] = nq;
      while (go[p][c] == q) {
        go[p][c] = nq;
        p = pre[p];
      }
    }
  }
}
int ask(int l, int r, int i, int j, int nod) {
  if (!nod || i > j) return 0;
  if (l == i && r == j) return tree[nod];
  int mid = (l + r) >> 1;
  if (j <= mid)
    return ask(l, mid, i, j, lson[nod]);
  else if (i > mid)
    return ask(mid + 1, r, i, j, rson[nod]);
  else
    return ask(mid + 1, r, mid + 1, j, rson[nod]) |
           ask(l, mid, i, mid, lson[nod]);
}
inline int merge(int a, int b) {
  if (a == 0 || b == 0) return a | b;
  int k = ++nodecnt;
  lson[k] = merge(lson[a], lson[b]);
  rson[k] = merge(rson[a], rson[b]);
  if (lson[k] || rson[k])
    tree[k] = tree[lson[k]] | tree[rson[k]];
  else
    tree[k] = tree[a] | tree[b];
  return k;
}
void insert(int l, int r, int pos, int de, int &nod) {
  if (!nod) nod = ++nodecnt;
  if (l == r) {
    tree[nod] |= 1 << de;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    insert(l, mid, pos, de, lson[nod]);
  else
    insert(mid + 1, r, pos, de, rson[nod]);
  tree[nod] = tree[lson[nod]] | tree[rson[nod]];
}
void init(int p) {
  if (rig[p] || p == 1) insert(0, n - 1, rig[p], ch[rig[p] + 1] - 'a', rt[p]);
  for (unsigned i = 0; i < v[p].size(); i++) {
    init(v[p][i]);
    rt[p] = merge(rt[p], rt[v[p][i]]);
  }
}
signed main() {
  scanf("%s", ch + 1);
  n = strlen(ch + 1);
  for (int i = 1; i < n; i++) {
    add(ch[i] - 'a');
    rig[last] = i;
  }
  rig[1] = 0;
  for (int i = 2; i <= tot; i++) v[pre[i]].push_back(i);
  init(1);
  int m = read();
  while (m--) {
    int l = read(), r = read(), dq = 1, p1 = -1, p2;
    string s;
    cin >> s;
    s += 'a' - 1;
    for (unsigned i = 0; i < s.length() && dq; i++) {
      int t = ask(0, n - 1, l - 1 + i, r - 1, rt[dq]), dd = s[i] + 1 - 'a';
      for (int j = dd; j < 26; j++)
        if (t >> j & 1) {
          p1 = i;
          p2 = j;
          break;
        }
      if (s[i] >= 'a') dq = go[dq][s[i] - 'a'];
    }
    if (p1 == -1) {
      puts("-1");
      continue;
    }
    for (int i = 0; i < p1; i++) putchar(s[i]);
    putchar('a' + p2);
    puts("");
  }
}