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 N = 2e5 + 50;
char s[N];
int n, l, r;
int pos[N];
int p[N];
struct SegmentTree {
  int tot, rt[N], ls[N * 40], rs[N * 40], sum[N * 40];
  void insert(int &now, int l, int r, int x) {
    if (!now) {
      now = ++tot;
    }
    sum[now] = 1;
    if (l < r) {
      if (x <= (l + r) / 2) {
        insert(ls[now], l, (l + r) / 2, x);
      } else {
        insert(rs[now], (l + r) / 2 + 1, r, x);
      }
    }
  }
  int merge(int a, int b) {
    if (!a || !b) {
      return a + b;
    }
    int now = ++tot;
    sum[now] = sum[a] | sum[b];
    ls[now] = merge(ls[a], ls[b]);
    rs[now] = merge(rs[a], rs[b]);
    return now;
  }
  int query(int now, int l, int r, int ql, int qr) {
    if (!now) {
      return 0;
    }
    if (ql <= l && qr >= r) {
      return sum[now];
    }
    if (!sum[now]) {
      return 0;
    }
    if (ql <= (l + r) / 2) {
      if (query(ls[now], l, (l + r) / 2, ql, qr)) {
        return 1;
      }
    }
    if (qr > (l + r) / 2) {
      if (query(rs[now], (l + r) / 2 + 1, r, ql, qr)) {
        return 1;
      }
    }
    return 0;
  }
  void debug(int now, int l, int r) {
    if (l == r) {
      printf("%d %d\n", l, sum[now]);
      return;
    }
    debug(ls[now], l, (l + r) / 2);
    debug(rs[now], (l + r) / 2 + 1, r);
  }
} ac;
struct SAM {
  int nex[N * 2][26], fa[N * 2], len[N * 2], num[N * 2];
  int cnt, lst;
  int w[N * 2], tp[N * 2];
  int newnode(int l, int s) {
    for (int i = 0; i < 26; i++) {
      nex[cnt][i] = 0;
    }
    len[cnt] = l;
    num[cnt] = s;
    return cnt++;
  }
  void init() {
    cnt = 1;
    lst = newnode(0, 0);
    fa[lst] = -1;
  }
  void add(int c) {
    c -= 'a';
    int p = lst;
    int cur = newnode(len[p] + 1, 1);
    while (p != -1 && !nex[p][c]) {
      nex[p][c] = cur;
      p = fa[p];
    }
    if (p == -1) {
      fa[cur] = 1;
    } else {
      int q = nex[p][c];
      if (len[q] == len[p] + 1) {
        fa[cur] = q;
      } else {
        int cl = newnode(len[p] + 1, 0);
        fa[cl] = fa[q];
        memcpy(nex[cl], nex[q], sizeof(nex[cl]));
        while (p != -1 && nex[p][c] == q) {
          nex[p][c] = cl;
          p = fa[p];
        }
        fa[q] = fa[cur] = cl;
      }
    }
    lst = cur;
  }
  void gao(int l) {
    for (int i = 0; i <= l; i++) {
      w[i] = 0;
    }
    for (int i = 2; i < cnt; i++) {
      w[len[i]]++;
    }
    for (int i = 2; i <= l; i++) {
      w[i] += w[i - 1];
    }
    for (int i = cnt - 1; i >= 2; i--) {
      tp[w[len[i]]--] = i;
    }
    for (int i = 1; i <= l; i++) {
      ac.insert(ac.rt[pos[i]], 1, l, i);
    }
    for (int i = cnt - 1; i >= 1; i--) {
      num[fa[tp[i]]] += num[tp[i]];
      ac.rt[fa[tp[i]]] = ac.merge(ac.rt[fa[tp[i]]], ac.rt[tp[i]]);
    }
  }
} sam;
struct solver {
  void gao(int l, int r, int len, int n) {
    int now = 1;
    int pre = len;
    for (int i = 1; i <= len; i++) {
      int idx = s[i] - 'a';
      if (sam.nex[now][idx]) {
        now = sam.nex[now][idx];
        p[i] = now;
      } else {
        pre = i - 1;
        break;
      }
    }
    p[0] = 1;
    for (int i = pre; i >= 0; i--) {
      for (int j = (i == len ? 0 : s[i + 1] - 'a' + 1); j < 26; j++) {
        if (ac.query(ac.rt[sam.nex[p[i]][j]], 1, n, l + i, r)) {
          for (int k = 1; k <= i; k++) {
            printf("%c", s[k]);
          }
          printf("%c\n", char('a' + j));
          return;
        }
      }
    }
    printf("-1\n");
  }
} solver;
int main() {
  scanf("%s", s + 1);
  int len = strlen(s + 1);
  sam.init();
  for (int i = 1; i <= len; i++) {
    sam.add(s[i]);
    pos[i] = sam.lst;
  }
  sam.gao(len);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%s", &l, &r, s + 1);
    int cd = strlen(s + 1);
    solver.gao(l, r, cd, len);
  }
  return 0;
}