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". 
#include <bits/stdc++.h>
using namespace std;
namespace IO {
inline char gc() {
  static char buf[1000000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <typename T>
inline void read(T &x) {
  x = (T)0;
  T f = 1;
  char ssd = gc();
  while (ssd < '0' || ssd > '9') f = ssd == '-' ? -1 : 1, ssd = gc();
  while (ssd >= '0' && ssd <= '9')
    x = (x << 3) + (x << 1) + (ssd - '0'), ssd = gc();
  x = x * f;
}
char OUT[1000000], *S = OUT, *T = OUT + 1000000;
char Num[1000000];
int toP;
inline void out() {
  fwrite(OUT, sizeof(char), S - OUT, stdout);
  S = OUT;
}
inline void pc(char ssd) {
  *S++ = ssd;
  if (S == T) out();
}
template <typename T>
inline void write(T x) {
  if (x == 0) pc('0');
  if (x < 0) x = -x, pc('-');
  toP = 0;
  while (x) Num[++toP] = x % 10 + '0', x /= 10;
  while (toP) pc(Num[toP--]);
}
};  // namespace IO
const int maxn = 4e5 + 10;
namespace SGT {
int sum[maxn << 5];
int ls[maxn << 5], rs[maxn << 5], Node;
inline void pushup(int NODE) { sum[NODE] = sum[ls[NODE]] + sum[rs[NODE]]; }
void change(int &NODE, int l, int r, int id) {
  if (!NODE) NODE = ++Node;
  if (l == r) {
    sum[NODE] += 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (mid >= id)
    change(ls[NODE], l, mid, id);
  else
    change(rs[NODE], mid + 1, r, id);
  pushup(NODE);
}
int query(int NODE, int l, int r, int L, int R) {
  if (L > R) return 0;
  if (!NODE || (L <= l && r <= R)) return sum[NODE];
  int re = 0;
  int mid = (l + r) >> 1;
  if (mid >= L) re += query(ls[NODE], l, mid, L, R);
  if (mid < R) re += query(rs[NODE], mid + 1, r, L, R);
  return re;
}
int merge(int root1, int root2, int l, int r) {
  if (!root1 || !root2) return root1 + root2;
  int New = ++Node;
  if (l == r) {
    sum[New] = sum[root1] + sum[root2];
    return New;
  } else {
    int mid = (l + r) >> 1;
    ls[New] = merge(ls[root1], ls[root2], l, mid);
    rs[New] = merge(rs[root1], rs[root2], mid + 1, r);
    pushup(New);
    return New;
  }
}
}  // namespace SGT
namespace Tham {
int root[maxn];
int len[maxn], fa[maxn], son[maxn][26], end = 1, tnt = 1;
inline int insert(int C, int last) {
  end = ++tnt;
  len[end] = len[last] + 1;
  while (last && son[last][C] == 0) son[last][C] = end, last = fa[last];
  if (!last) {
    fa[end] = 1;
    return end;
  }
  register int c = son[last][C];
  if (len[last] + 1 == len[c]) {
    fa[end] = c;
    return end;
  }
  len[++tnt] = len[last] + 1;
  for (register int i = 0; i < 26; i += 1) son[tnt][i] = son[c][i];
  fa[tnt] = fa[c], fa[c] = tnt;
  fa[end] = tnt;
  while (son[last][C] == c) son[last][C] = tnt, last = fa[last];
  return end;
}
}  // namespace Tham
int Len;
char ssd[maxn], S[maxn];
int head[maxn], to[maxn], nxt[maxn], tot;
inline void add(int x, int y) {
  nxt[++tot] = head[x];
  head[x] = tot;
  to[tot] = y;
}
void dfs(int now) {
  for (register int i = head[now]; i; i = nxt[i]) {
    dfs(to[i]);
    Tham::root[now] = SGT::merge(Tham::root[now], Tham::root[to[i]], 1, Len);
  }
}
int pos[maxn], id[maxn];
int main() {
  scanf("%s", S + 1);
  Len = strlen(S + 1);
  id[0] = pos[0] = 1;
  for (register int i = 1; i <= Len; i += 1)
    pos[i] = Tham::insert(S[i] - 'a', pos[i - 1]),
    SGT::change(Tham::root[pos[i]], 1, Len, i);
  for (register int i = 2; i <= Tham::tnt; i += 1) add(Tham::fa[i], i);
  dfs(1);
  int T;
  scanf("%d", &T);
  while (T--) {
    int l, r;
    scanf("%d %d %s", &l, &r, ssd + 1);
    int LL = strlen(ssd + 1), match = 0;
    for (register int i = 1; i <= LL; i += 1) {
      if (Tham::son[id[i - 1]][ssd[i] - 'a'])
        id[i] = Tham::son[id[i - 1]][ssd[i] - 'a'], match += 1;
      else
        break;
    }
    bool ccf = false;
    for (register int i = match; i >= 0; i -= 1) {
      for (register int color = (i < LL ? ssd[i + 1] - 'a' + 1 : 0); color < 26;
           color += 1)
        if (Tham::son[id[i]][color]) {
          int nxt = Tham::son[id[i]][color];
          if (SGT::query(Tham::root[nxt], 1, Len, l + i, r)) {
            for (register int j = 1; j <= i; j += 1) printf("%c", ssd[j]);
            printf("%c\n", char(color + 97));
            ccf = true;
            break;
          }
        }
      if (ccf) break;
    }
    if (!ccf) puts("-1");
  }
  return 0;
}
