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>
clock_t t = clock();
namespace my_std {
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
inline T rnd(T l, T r) {
  return uniform_int_distribution<T>(l, r)(rng);
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T &t) {
  t = 0;
  char f = 0, ch = getchar();
  double d = 0.1;
  while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
  while (ch <= '9' && ch >= '0') t = t * 10 + ch - 48, ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t = (f ? -t : t);
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}
char __sr[1 << 21], __z[20];
int __C = -1, __zz = 0;
inline void Ot() { fwrite(__sr, 1, __C + 1, stdout), __C = -1; }
inline void print(register int x) {
  if (__C > 1 << 20) Ot();
  if (x < 0) __sr[++__C] = '-', x = -x;
  while (__z[++__zz] = x % 10 + 48, x /= 10)
    ;
  while (__sr[++__C] = __z[__zz], --__zz)
    ;
  __sr[++__C] = '\n';
}
void file() {}
inline void chktime() {}
long long ksm(long long x, int y) {
  long long ret = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) ret = ret * x;
  return ret;
}
}  // namespace my_std
using namespace my_std;
int n;
char s[202020];
struct hh {
  int link, len, ch[28], edp;
} a[202020];
int last = 1, cnt = 1;
void insert(int c, int pp) {
  int cur = ++cnt;
  a[cur].edp = pp;
  int p = last;
  last = cur;
  a[cur].len = a[p].len + 1;
  while (!a[p].ch[c]) a[p].ch[c] = cur, p = a[p].link;
  if (!p) return void(a[cur].link = 1);
  int q = a[p].ch[c];
  if (a[q].len == a[p].len + 1) return void(a[cur].link = q);
  int t = ++cnt;
  a[t] = a[q];
  a[t].len = a[p].len + 1;
  a[t].edp = 0;
  while (a[p].ch[c] == q) a[p].ch[c] = t, p = a[p].link;
  a[q].link = a[cur].link = t;
}
int tr[202020 * 20], ls[202020 * 20], rs[202020 * 20], cc;
int root[202020];
void insert(int &k, int l, int r, int x) {
  if (!k) k = ++cc;
  tr[k] = 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (x <= mid)
    insert(ls[k], l, mid, x);
  else
    insert(rs[k], mid + 1, r, x);
}
int merge(int k1, int k2, int l, int r) {
  if (!k1 || !k2) return k1 + k2;
  int k = ++cc;
  tr[k] = tr[k1] | tr[k2];
  int mid = (l + r) >> 1;
  ls[k] = merge(ls[k1], ls[k2], l, mid);
  rs[k] = merge(rs[k1], rs[k2], mid + 1, r);
  return k;
}
int query(int k, int l, int r, int x, int y) {
  if (!k || x > y) return 0;
  if (x <= l && r <= y) return tr[k];
  int mid = (l + r) >> 1;
  if (x <= mid && query(ls[k], l, mid, x, y)) return 1;
  if (y > mid && query(rs[k], mid + 1, r, x, y)) return 1;
  return 0;
}
int c[202020], id[202020];
void init() {
  for (int i = (1); i <= (n); i++) insert(s[i] - 'a' + 1, i);
  for (int i = (1); i <= (cnt); i++) ++c[a[i].len];
  for (int i = (1); i <= (n); i++) c[i] += c[i - 1];
  for (int i = (cnt); i >= (1); i--) id[c[a[i].len]--] = i;
  for (int i = (cnt); i >= (1); i--) {
    int x = id[i];
    if (a[x].edp) insert(root[x], 1, n, a[x].edp);
    root[a[x].link] = merge(root[a[x].link], root[x], 1, n);
  }
}
int L, R;
char ss[202020];
int m;
int p[202020];
void Query() {
  m = strlen(ss + 1);
  int lim = m, cur = 1;
  p[0] = 1;
  for (int i = (1); i <= (m); i++)
    if (!(cur = a[cur].ch[ss[i] - 'a' + 1])) {
      lim = i - 1;
      break;
    } else
      p[i] = cur;
  ss[m + 1] = 'a' - 1;
  for (int i = (lim); i >= (0); i--)
    for (int j = (ss[i + 1] - 'a' + 1 + 1); j <= (26); j++)
      if (a[p[i]].ch[j] && query(root[a[p[i]].ch[j]], 1, n, L + i, R)) {
        for (int k = (1); k <= (i); k++) putchar(ss[k]);
        putchar(j - 1 + 'a');
        puts("");
        return;
      }
  puts("-1");
}
int main() {
  file();
  cin >> (s + 1);
  n = strlen(s + 1);
  init();
  int Q;
  read(Q);
  while (Q--) {
    read(L, R);
    cin >> (ss + 1);
    Query();
  }
  return 0;
}