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;
int table[1 << 18][2];
constexpr int maxN = 100010;
constexpr int maxQ = 200010;
constexpr int maxX = 200010;
constexpr int inf = 1 << 30;
char s[maxN], x[maxX];
int n, sa[maxN], rk[maxN * 2], tmp[maxN], c1[maxN], c2[maxN], lcp[maxN];
void make() {
  while (s[n]) n++;
  for (int i = 0; i < n; ++i) c1[s[i]] = 1;
  for (int i = 1; i < 128; ++i) c1[i] += c1[i - 1];
  for (int i = 0; i < n; ++i) rk[i] = c1[s[i]];
  for (int k = 1, tot = c1[127]; tot < n; k *= 2) {
    for (int i = 0; i <= tot; ++i) c1[i] = c2[i] = 0;
    for (int i = 0; i < n; ++i)
      static_cast<void>(c1[rk[i] + 1]++), c2[rk[i + k] + 1]++;
    for (int i = 1; i <= tot; ++i)
      static_cast<void>(c1[i] += c1[i - 1]), c2[i] += c2[i - 1];
    for (int i = 0; i < n; ++i) tmp[c2[rk[i + k]]++] = i;
    for (int *i = tmp; i < tmp + n; ++i) sa[c1[rk[*i]]++] = *i;
    for (int i = tot = 0; i < n; ++i)
      tmp[sa[i]] =
          i && rk[sa[i]] == rk[sa[i - 1]] && rk[sa[i] + k] == rk[sa[i - 1] + k]
              ? tot
              : ++tot;
    for (int i = 0; i < n; ++i) rk[i] = tmp[i];
  }
  for (int i = 0; i < n; ++i) sa[--rk[i]] = i;
  for (int i = 0, h = 0; i < n; lcp[rk[i++]] = h)
    for (h ? --h : 1; rk[i] + 1 < n && s[i + h] == s[sa[rk[i] + 1] + h]; h++)
      ;
}
struct QueryList {
  int l, r, p, a, ap;
  QueryList *next;
} queryList[maxQ], *fQueryList[maxN];
inline int mid(int l, int r) { return (l + r >> 1); };
void build(int m, int l, int r) {
  table[m][0] = inf;
  if (r - l == 1)
    table[m][1] = lcp[l];
  else
    build(m << 1, l, mid(l, r)), build(m << 1 | 1, mid(l, r), r),
        table[m][1] = min(table[m << 1][1], table[m << 1 | 1][1]);
}
void insert(int m, int l, int r, int i, int x) {
  if (r - l == 1)
    table[m][0] = x;
  else
    i < mid(l, r) ? insert(m << 1, l, mid(l, r), i, x)
                  : insert(m << 1 | 1, mid(l, r), r, i, x),
        table[m][0] = min(table[m << 1][0], table[m << 1 | 1][0]);
}
int query(int m, int l, int r, int t, int k, int p) {
  if (table[m][t] >= p) return r;
  if (r - l == 1) return l;
  if (k >= mid(l, r)) return query(m << 1 | 1, mid(l, r), r, t, k, p);
  const int ret = query(m << 1, l, mid(l, r), t, k, p);
  if (ret < mid(l, r)) return ret;
  return query(m << 1 | 1, mid(l, r), r, t, k, p);
}
int main() {
  scanf("%s", s);
  make();
  int q, l, r;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d%d%s", &l, &r, x);
    --l;
    int left = -1, right = n, mid, p = 0;
    while (right - left > 1) {
      mid = left + right >> 1;
      if (strcmp(s + sa[mid], x) > 0)
        right = mid;
      else
        left = mid;
    }
    while (x[p] && right < n && s[sa[right] + p] == x[p]) p++;
    queryList[i] = (QueryList){right, r, p, -1, 0, fQueryList[l]};
    fQueryList[l] = queryList + i;
  }
  build(1, 0, n);
  for (int i = n; i >= 0; --i) {
    if (i < n) insert(1, 0, n, rk[i], i);
    for (QueryList *j = fQueryList[i]; j; j = j->next) {
      for (int l = j->l, r, p = j->p; l < n && j->a == -1;
           p = lcp[r], l = r + 1) {
        r = p ? query(1, 0, n, 1, l, p) : n - 1;
        const int s = query(1, 0, n, 0, l, j->r - p);
        if (s <= r) j->a = sa[s], j->ap = p;
      }
    }
  }
  for (QueryList *i = queryList; i < queryList + q; ++i) {
    if (i->a < 0)
      puts("-1");
    else {
      for (int j = 0; j <= i->ap; ++j) putchar(s[i->a + j]);
      puts("");
    }
  }
  return 0;
}