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 = 1e5 + 7;
char s[N], st[N];
int n;
struct SAM {
  int maxlen[N << 2], trans[N << 2][26], link[N << 2], size, last;
  SAM() { size = last = 1; }
  void Extend(int id) {
    int cur = ++size, p;
    maxlen[cur] = maxlen[last] + 1;
    for (p = last; p && !trans[p][id]; p = link[p]) trans[p][id] = cur;
    if (!p)
      link[cur] = 1;
    else {
      int q = trans[p][id];
      if (maxlen[q] == maxlen[p] + 1)
        link[cur] = q;
      else {
        int clone = ++size;
        maxlen[clone] = maxlen[p] + 1;
        link[clone] = link[q];
        memcpy(trans[clone], trans[q], sizeof trans[q]);
        for (; p && trans[p][id] == q; p = link[p]) trans[p][id] = clone;
        link[q] = link[cur] = clone;
      }
    }
    last = cur;
  }
} T;
int ls[N << 7], rs[N << 7], rt[N << 2], edp[N << 2], tot;
int wfl, wfr;
void add(int &rt, int l, int r, int v) {
  if (!rt) rt = ++tot;
  if (l == r) return;
  int mid = l + r >> 1;
  if (v <= mid)
    add(ls[rt], l, mid, v);
  else
    add(rs[rt], mid + 1, r, v);
}
int merge(int &x, int &y) {
  if (!x || !y) return x | y;
  int pos = ++tot;
  ls[pos] = merge(ls[x], ls[y]);
  rs[pos] = merge(rs[x], rs[y]);
  return pos;
}
bool querry(int rt, int l, int r) {
  if (!rt) return 0;
  if (wfl <= l && wfr >= r) return 1;
  int mid = l + r >> 1;
  bool fl = 0;
  if (wfl <= mid) fl |= querry(ls[rt], l, mid);
  if (wfr > mid) fl |= querry(rs[rt], mid + 1, r);
  return fl;
}
vector<int> vc[N << 2];
void dfs(int u) {
  if (edp[u]) {
    add(rt[u], 1, n, edp[u]);
  }
  for (int i = 0; i < vc[u].size(); i++) {
    int v = vc[u][i];
    dfs(v);
    rt[u] = merge(rt[u], rt[v]);
  }
}
int sp[N << 2];
bool check(int u, int len) {
  bool ans;
  wfl += len - 1;
  if (wfl > wfr)
    ans = 0;
  else
    ans = querry(rt[u], 1, n);
  wfl -= len - 1;
  return ans;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) T.Extend(s[i] - 'a'), edp[T.last] = i;
  for (int i = 1; i <= T.size; i++) vc[T.link[i]].push_back(i);
  dfs(1);
  int Q, len;
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d%d%s", &wfl, &wfr, st + 1);
    len = strlen(st + 1);
    int p, sav, v;
    char las = 100;
    sp[sav = 0] = p = 1;
    for (int i = 1; i <= len; i++) {
      v = T.trans[p][st[i] - 'a'];
      if (v && check(v, i))
        sp[sav = i] = p = v;
      else
        break;
    }
    st[len + 1] = (char)('a' - 1);
    for (; las == 100 && sav >= 0; sav--) {
      p = sp[sav];
      for (int j = (int)(st[sav + 1] - 'a') + 1; j < 26; j++) {
        v = T.trans[p][j];
        if (v && check(v, sav + 1)) {
          las = j;
          break;
        }
      }
    }
    if (las == 100)
      puts("-1");
    else {
      for (int i = 1; i <= sav + 1; i++) putchar(st[i]);
      putchar(las + 'a');
      putchar('\n');
    }
  }
  return 0;
}