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 maxn = 2e5 + 10;
int N;
namespace Segtree {
const int maxt = 10000005;
int son[2][maxt], root[maxn], Cnode;
int getnewnode() {
  ++Cnode;
  son[0][Cnode] = son[1][Cnode] = 0;
  return Cnode;
}
void add(int& x, int l, int r, int p) {
  if (!x) x = getnewnode();
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (p <= mid)
    add(son[0][x], l, mid, p);
  else
    add(son[1][x], mid + 1, r, p);
}
int merge(int p, int q) {
  if (!p && !q) return 0;
  int cur = getnewnode();
  if (!p || !q) {
    son[0][cur] = son[0][p + q];
    son[1][cur] = son[1][p + q];
  } else {
    son[0][cur] = merge(son[0][p], son[0][q]);
    son[1][cur] = merge(son[1][p], son[1][q]);
  }
  return cur;
}
bool check(int x, int l, int r, int tl, int tr) {
  if (!x) return false;
  if (l > tr || r < tl) return false;
  if (tl <= l && r <= tr) return true;
  int mid = (l + r) >> 1;
  return check(son[0][x], l, mid, tl, tr) ||
         check(son[1][x], mid + 1, r, tl, tr);
}
}  // namespace Segtree
char S[maxn];
namespace SAM {
int link[maxn], len[maxn], trans[maxn][26];
int root, lastnode, Cnode;
vector<vector<int> > g;
int getnewnode() {
  link[Cnode] = 0;
  len[Cnode] = 0;
  for (int i = 0; i < 26; i++) trans[Cnode][i] = 0;
  return Cnode++;
}
void init() {
  Cnode = 0;
  lastnode = root = getnewnode();
  link[root] = -1;
}
void extend(int ch) {
  int cur = getnewnode();
  len[cur] = len[lastnode] + 1;
  int p;
  for (p = lastnode; ~p && !trans[p][ch]; p = link[p]) {
    trans[p][ch] = cur;
  }
  lastnode = cur;
  if (p == -1) {
    link[cur] = root;
    return;
  }
  int q = trans[p][ch];
  if (len[q] == len[p] + 1) {
    link[cur] = q;
    return;
  } else {
    int copy = getnewnode();
    len[copy] = len[p] + 1;
    for (int i = 0; i < 26; i++) trans[copy][i] = trans[q][i];
    link[copy] = link[q];
    link[q] = link[cur] = copy;
    for (; ~p && trans[p][ch] == q; p = link[p]) trans[p][ch] = copy;
    return;
  }
}
void build() {
  g.resize(Cnode);
  for (int i = 1; i < Cnode; i++) {
    g[link[i]].push_back(i);
  }
}
void dfs(int p) {
  for (int i = 0; i < g[p].size(); i++) {
    int to = g[p][i];
    dfs(to);
    Segtree::root[p] = Segtree::merge(Segtree::root[p], Segtree::root[to]);
  }
}
bool solve(char* S, int total, int l, int r, int cur = root, int len = 0) {
  if (len > r - l + 1) return false;
  if (len == total) {
    for (int nxt = 0; nxt < 26; nxt++) {
      if (trans[cur][nxt]) {
        int to = trans[cur][nxt];
        if (Segtree::check(Segtree::root[to], 0, N - 1, l + len, r)) {
          for (int i = 0; i < total; i++) printf("%c", S[i]);
          printf("%c\n", 'a' + nxt);
          return true;
        }
      }
    }
    return false;
  }
  int nxt = S[len] - 'a';
  if (trans[cur][nxt] && solve(S, total, l, r, trans[cur][nxt], len + 1))
    return true;
  for (nxt = nxt + 1; nxt < 26; nxt++) {
    if (trans[cur][nxt]) {
      int to = trans[cur][nxt];
      if (Segtree::check(Segtree::root[to], 0, N - 1, l + len, r)) {
        for (int i = 0; i < len; i++) printf("%c", S[i]);
        printf("%c\n", 'a' + nxt);
        return true;
      }
    }
  }
  return false;
}
}  // namespace SAM
char buf[maxn];
int main() {
  scanf("%s", S);
  SAM::init();
  N = strlen(S);
  for (int i = 0; i < N; i++) {
    SAM::extend(S[i] - 'a');
    int lastid = SAM::lastnode;
    Segtree::add(Segtree::root[lastid], 0, N - 1, i);
  }
  SAM::build();
  SAM::dfs(SAM::root);
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    scanf("%s", buf);
    int n = strlen(buf);
    if (!SAM::solve(buf, n, l - 1, r - 1)) {
      printf("-1\n");
    }
  }
  return 0;
}