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;
using ll = long long;
inline int read();
const int M = 200016, MOD = 1000000007;
int sz;
int ch[M][26], len[M], link[M], pre[M];
void extend(const char *s) {
  for (int i = 0, lst = 0; s[i]; ++i) {
    int c = s[i] - 'a', cur = ++sz;
    len[cur] = len[lst] + 1;
    int p = lst;
    while (!ch[p][c]) ch[p][c] = cur, p = link[p];
    if (ch[p][c] != cur) {
      int q = ch[p][c];
      if (len[p] + 1 == len[q])
        link[cur] = q;
      else {
        int clone = ++sz;
        memcpy(ch[clone], ch[q], sizeof(ch[q]));
        link[clone] = link[q];
        len[clone] = len[p] + 1;
        while (ch[p][c] == q) ch[p][c] = clone, p = link[p];
        link[q] = link[cur] = clone;
      }
    }
    lst = cur;
    pre[cur] = i + 1;
  }
}
pair<int, int> qrys[M * 2 * 26];
int qcnt;
int qans[M * 2 * 26];
vector<int> sons[M];
vector<int> qry[M];
set<int> st[M];
int tar[M];
void merge(int a, int b) {
  if (st[tar[a]].size() < st[tar[b]].size()) swap(a, b);
  for (auto x : st[tar[b]]) st[tar[a]].insert(x);
  st[tar[b]].clear();
  tar[b] = tar[a];
}
void solve(int u) {
  for (auto v : sons[u]) solve(v), merge(u, v);
  for (auto qid : qry[u]) {
    int l = qrys[qid].first, r = qrys[qid].second;
    auto it = st[tar[u]].lower_bound(l);
    if (it != st[tar[u]].end() && *it <= r) qans[qid] = 1;
  }
}
char tex[M], pat[M * 2];
int lef[M], rig[M], pid[M], pln[M], pcnt;
int solved[M];
void foreach_query(int ftq, int id, int now, int tag) {
  if (pat[id] && ch[now][pat[id] - 'a'])
    foreach_query(ftq, id + 1, ch[now][pat[id] - 'a'], tag);
  for (int c = pat[id] ? pat[id] + 1 : 'a'; c <= 'z'; ++c) {
    int tmp = ch[now][c - 'a'];
    if (tmp && rig[ftq] - lef[ftq] >= id - pid[ftq]) {
      ++qcnt;
      if (tag == 0) {
        qrys[qcnt] = {lef[ftq] + id - pid[ftq], rig[ftq]};
        qry[tmp].push_back(qcnt);
      } else if (qans[qcnt] == 1 && !solved[ftq]) {
        solved[ftq] = 1;
        for (int xj = pid[ftq]; xj < id; ++xj) putchar(pat[xj]);
        putchar(c);
        printf("\n");
      }
    }
  }
}
int main(void) {
  scanf("%s", tex);
  extend(tex);
  for (int i = 1; i <= sz; ++i) sons[link[i]].push_back(i);
  for (int i = 0; i <= sz; ++i) {
    tar[i] = i;
    if (pre[i]) st[i].insert(pre[i]);
  }
  int q = read();
  for (int i = 1; i <= q; ++i) {
    lef[i] = read(), rig[i] = read(), pid[i] = pcnt;
    scanf("%s", pat + pid[i]);
    pln[i] = strlen(pat + pid[i]);
    pcnt += pln[i] + 1;
    foreach_query(i, pid[i], 0, 0);
  }
  solve(0);
  qcnt = 0;
  for (int i = 1; i <= q; ++i) {
    foreach_query(i, pid[i], 0, 1);
    if (!solved[i]) printf("-1\n");
  }
  return 0;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}