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 + 5;
const int mod = 1000000007;
int n;
struct SegmentTree {
  struct node {
    int ls, rs;
  } s[maxn * 20];
  int nodecnt = 0, rt[maxn];
  void update(int x, int &pos, int l = 1, int r = n) {
    if (!pos) pos = ++nodecnt;
    if (l == r) return;
    int mid = l + r >> 1;
    if (x <= mid)
      update(x, s[pos].ls, l, mid);
    else
      update(x, s[pos].rs, mid + 1, r);
  }
  bool query(int l, int r, int ql, int qr, int pos) {
    if (!pos || ql > qr) return 0;
    if (ql == l && qr == r) return 1;
    int mid = l + r >> 1;
    if (qr <= mid)
      return query(l, mid, ql, qr, s[pos].ls);
    else if (ql > mid)
      return query(mid + 1, r, ql, qr, s[pos].rs);
    else
      return query(l, mid, ql, mid, s[pos].ls) |
             query(mid + 1, r, mid + 1, qr, s[pos].rs);
  }
  int merge(int x, int y) {
    if (!x) return y;
    if (!y) return x;
    int pos = ++nodecnt;
    s[pos].ls = merge(s[x].ls, s[y].ls);
    s[pos].rs = merge(s[x].rs, s[y].rs);
    return pos;
  }
} sgt;
struct SAM {
  struct state {
    int len, link;
    int next[26];
  } st[maxn];
  int sz, last;
  void init() {
    st[0].len = 0;
    st[0].link = -1;
    sz = 1;
    last = 0;
  }
  void extend(int c) {
    int cur = sz++;
    st[cur].len = st[last].len + 1;
    sgt.update(st[cur].len, sgt.rt[cur]);
    int p = last;
    while (p != -1 && !st[p].next[c]) {
      st[p].next[c] = cur;
      p = st[p].link;
    }
    if (p == -1)
      st[cur].link = 0;
    else {
      int q = st[p].next[c];
      if (st[q].len == st[p].len + 1)
        st[cur].link = q;
      else {
        int clone = sz++;
        st[clone] = st[q];
        st[clone].len = st[p].len + 1;
        while (p != -1 && st[p].next[c] == q) {
          st[p].next[c] = clone;
          p = st[p].link;
        }
        st[q].link = st[cur].link = clone;
      }
    }
    last = cur;
  }
} sam;
char s[maxn], ans[maxn];
int lst[maxn];
vector<int> g[maxn];
void dfs(int x) {
  for (int i = (0); i < (g[x].size()); i++) {
    dfs(g[x][i]);
    if (x != 0) sgt.rt[x] = sgt.merge(sgt.rt[x], sgt.rt[g[x][i]]);
  }
}
int main() {
  scanf("%s", s + 1);
  sam.init();
  n = strlen(s + 1);
  for (int i = (1); i <= (n); i++) sam.extend(s[i] - 'a');
  for (int i = (1); i <= (sam.sz - 1); i++) {
    g[sam.st[i].link].push_back(i);
  }
  dfs(0);
  int q;
  scanf("%d", &q);
  while (q--) {
    int L, R;
    scanf("%d", &L);
    scanf("%d", &R);
    scanf("%s", s + 1);
    int m = strlen(s + 1);
    s[m + 1] = 1;
    int now = 0, anslen = 0;
    bool flag = 0;
    for (int i = (1); i <= (m + 1); i++) {
      if (i == m + 1 || !sam.st[now].next[s[i] - 'a'] ||
          !sgt.query(1, n, L + anslen, R,
                     sgt.rt[sam.st[now].next[s[i] - 'a']])) {
        while (1) {
          for (int j = (max(0, s[anslen + 1] - 'a' + 1)); j <= (25); j++) {
            if (sam.st[now].next[j] &&
                sgt.query(1, n, L + anslen, R, sgt.rt[sam.st[now].next[j]])) {
              flag = 1;
              ans[++anslen] = 'a' + j;
              break;
            }
          }
          if (flag)
            break;
          else {
            if (now == 0)
              break;
            else
              now = lst[now], anslen--;
          }
        }
        break;
      } else {
        lst[sam.st[now].next[s[i] - 'a']] = now;
        now = sam.st[now].next[s[i] - 'a'];
        ans[++anslen] = s[i];
      }
    }
    if (!anslen)
      puts("-1");
    else {
      for (int i = (1); i <= (anslen); i++) putchar(ans[i]);
      puts("");
    }
  }
}