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 int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 200010;
int N, Ns;
char str[MAXN + 1];
int dis[MAXN + 1], ch[MAXN + 1][26], slink[MAXN + 1], End[MAXN + 1], tot, Last,
    RT;
inline int Nod(int d) {
  dis[tot] = d;
  memset(ch[tot], 0, sizeof(ch[tot]));
  slink[tot] = 0;
  return tot++;
}
inline void extend(int c, int pos) {
  int p = Last, np = Nod(dis[p] + 1);
  End[np] = pos;
  while (!ch[p][c]) ch[p][c] = np, p = slink[p];
  if (p == RT && ch[p][c] == np)
    slink[np] = RT;
  else {
    int q = ch[p][c];
    if (dis[q] == dis[p] + 1)
      slink[np] = q;
    else {
      int nq = Nod(dis[p] + 1);
      slink[nq] = slink[q], slink[q] = slink[np] = nq;
      memcpy(ch[nq], ch[q], sizeof(ch[nq]));
      while (ch[p][c] == q) ch[p][c] = nq, p = slink[p];
    }
  }
  Last = np;
}
int Node[MAXN << 1], Next[MAXN << 1], Root[MAXN + 1], cnt;
int DFN[MAXN + 1], rev[MAXN + 1], sz[MAXN + 1], id;
inline void insert(int u, int v) {
  Node[++cnt] = v;
  Next[cnt] = Root[u];
  Root[u] = cnt;
  return;
}
inline void DFS(int k) {
  DFN[k] = ++id, rev[id] = k, sz[k] = 1;
  for (int x = Root[k]; x; x = Next[x]) DFS(Node[x]), sz[k] += sz[Node[x]];
}
int Rt[MAXN + 1], sm[MAXN << 6], ls[MAXN << 6], rs[MAXN << 6], totSeg;
inline void build(int rt, int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  ls[rt] = ++totSeg, rs[rt] = ++totSeg;
  build(ls[rt], l, mid), build(rs[rt], mid + 1, r);
}
inline void mdf(int rt, int pre, int l, int r, int x) {
  sm[rt] = sm[pre] + 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  ls[rt] = ls[pre], rs[rt] = rs[pre];
  if (x <= mid)
    ls[rt] = ++totSeg, mdf(ls[rt], ls[pre], l, mid, x);
  else
    rs[rt] = ++totSeg, mdf(rs[rt], rs[pre], mid + 1, r, x);
}
inline int qry(int rt, int pre, int l, int r, int L, int R) {
  if (L <= l && r <= R) return sm[rt] - sm[pre];
  int mid = (l + r) >> 1, ret = 0;
  if (L <= mid) ret += qry(ls[rt], ls[pre], l, mid, L, R);
  if (R > mid) ret += qry(rs[rt], rs[pre], mid + 1, r, L, R);
  return ret;
}
inline bool Judge(int k, int L, int R) {
  int A = DFN[k], B = DFN[k] + sz[k] - 1;
  return qry(Rt[B], Rt[A - 1], 1, N, L, R);
}
int top, sta[MAXN + 1];
inline bool solve(int k, int L, int R, int len) {
  bool flag = 0;
  if (len == Ns + 1) {
    for (int i = 0; i < 26; i++) {
      if (ch[k][i] && Judge(ch[k][i], L, R)) {
        top = len, sta[top] = i, flag = 1;
        break;
      }
    }
    return flag;
  }
  if (ch[k][str[len] - 'a']) {
    int v = ch[k][str[len] - 'a'];
    if (Judge(v, L, R)) flag = solve(v, L + 1, R, len + 1);
    if (flag) sta[len] = str[len] - 'a';
  }
  if (flag) return flag;
  for (int i = str[len] - 'a' + 1; i < 26; i++)
    if (ch[k][i] && Judge(ch[k][i], L, R)) {
      top = len, sta[top] = i, flag = 1;
      break;
    }
  return flag;
}
int main() {
  scanf("%s", str + 1);
  N = strlen(str + 1);
  Last = RT = Nod(0);
  for (int i = 1; i <= N; i++) extend(str[i] - 'a', i);
  for (int i = 1; i < tot; i++) insert(slink[i], i);
  DFS(0);
  build(Rt[0] = totSeg = 1, 1, N);
  for (int i = 1; i <= id; i++)
    if (End[rev[i]])
      mdf(Rt[i] = ++totSeg, Rt[i - 1], 1, N, End[rev[i]]);
    else
      Rt[i] = Rt[i - 1];
  int Q = read();
  while (Q--) {
    int x = read(), y = read();
    scanf("%s", str + 1);
    Ns = strlen(str + 1);
    if (!solve(0, x, y, 1))
      printf("-1\n");
    else {
      for (int i = 1; i <= top; i++) printf("%c", sta[i] + 'a');
      printf("\n");
    }
  }
  return 0;
}