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>
const int N = 2e5;
using namespace std;
int n, q;
char ch[N + 5], t[N + 5];
struct Seg {
  int lc[N * 80 + 5], rc[N * 80 + 5], node_cnt;
  bool s[N * 80 + 5];
  void pushup(int k) { s[k] = s[lc[k]] | s[rc[k]]; }
  void insert(int &k, int l, int r, int x) {
    if (!k) k = ++node_cnt;
    if (l == r) {
      s[k] = 1;
      return;
    }
    int mid = l + r >> 1;
    if (x <= mid)
      insert(lc[k], l, mid, x);
    else
      insert(rc[k], mid + 1, r, x);
    pushup(k);
  }
  int merge(int x, int y, int l, int r) {
    if (!x || !y) return x + y;
    int k = ++node_cnt;
    s[k] = s[x] | s[y];
    if (l == r) return k;
    int mid = l + r >> 1;
    lc[k] = merge(lc[x], lc[y], l, mid);
    rc[k] = merge(rc[x], rc[y], mid + 1, r);
    pushup(k);
    return k;
  }
  bool query(int k, int l, int r, int x, int y) {
    if (x > y) return 0;
    if (!k) return 0;
    if (l >= x && r <= y) return s[k];
    int mid = l + r >> 1;
    if (y <= mid) return query(lc[k], l, mid, x, y);
    if (x > mid) return query(rc[k], mid + 1, r, x, y);
    return query(lc[k], l, mid, x, y) | query(rc[k], mid + 1, r, x, y);
  }
} tree;
struct SAM {
  int ch[N * 2 + 5][26], fa[N * 2 + 5], len[N * 2 + 5], node_cnt, las,
      ep[N * 2 + 5], edge[N * 2 + 5], nxt[N * 2 + 5], head[N * 2 + 5], edge_cnt,
      rt[N * 2 + 5];
  char ans[N + 5];
  SAM() { node_cnt = las = 1; }
  void add_edge(int u, int v) {
    edge[++edge_cnt] = v;
    nxt[edge_cnt] = head[u];
    head[u] = edge_cnt;
  }
  void insert(int c, int id) {
    int np = ++node_cnt, p = las;
    las = np;
    len[np] = len[p] + 1;
    ep[np] = id;
    while (p && !ch[p][c]) {
      ch[p][c] = np;
      p = fa[p];
    }
    if (!p)
      fa[np] = 1;
    else {
      int q = ch[p][c];
      if (len[q] == len[p] + 1)
        fa[np] = q;
      else {
        int nq = ++node_cnt;
        fa[nq] = fa[q];
        len[nq] = len[p] + 1;
        for (int i = 0; i < 26; i++) ch[nq][i] = ch[q][i];
        fa[q] = fa[np] = nq;
        while (p && ch[p][c] == q) {
          ch[p][c] = nq;
          p = fa[p];
        }
      }
    }
  }
  void dfs(int u) {
    for (int i = head[u]; i; i = nxt[i]) {
      int v = edge[i];
      dfs(v);
      rt[u] = tree.merge(rt[u], rt[v], 1, n);
    }
    if (ep[u]) tree.insert(rt[u], 1, n, ep[u]);
  }
  void build(char *ch) {
    for (int i = 1; i <= n; i++) insert(ch[i] - 'a', i);
    for (int i = 2; i <= node_cnt; i++) add_edge(fa[i], i);
    dfs(1);
  }
  void query(int l, int r, char *t) {
    int Len = strlen(t + 1), u = 1;
    t[Len + 1] = 'a' - 1;
    for (int i = 1; i <= Len + 1; i++) ans[i] = 0;
    for (int i = 1; i <= Len + 1; i++) {
      for (int j = t[i] + 1 - 'a'; j < 26; j++)
        if (ch[u][j]) {
          if (tree.query(rt[ch[u][j]], 1, n, l + i - 1, r)) {
            ans[i] = j + 'a';
            break;
          }
        }
      if (i == Len + 1) break;
      int c = t[i] - 'a';
      if (!ch[u][c]) break;
      u = ch[u][c];
      if (!tree.query(rt[u], 1, n, l + i - 1, r)) break;
    }
    for (int i = Len + 1; i >= 1; i--)
      if (ans[i]) {
        for (int j = 1; j < i; j++) printf("%c", t[j]);
        printf("%c\n", ans[i]);
        return;
      }
    printf("-1\n");
  }
} s;
int main() {
  scanf("%s", ch + 1);
  n = strlen(ch + 1);
  s.build(ch);
  scanf("%d", &q);
  int l, r;
  while (q--) {
    scanf("%d%d%s", &l, &r, t + 1);
    s.query(l, r, t);
  }
  return 0;
}