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;
void read(int &x) {
  char ch = getchar();
  x = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - 48, ch = getchar();
}
char ch[200000 + 1];
int n, m, rt[200000 + 1];
struct Tree {
  int sz[200000 << 5], lson[200000 << 5], rson[200000 << 5], tot;
  Tree() { tot = 0; }
  void Add(int &t, int l, int r, int k) {
    if (!t) t = ++tot;
    ++sz[t];
    if (l == r) return;
    int mid = l + r >> 1;
    k <= mid ? Add(lson[t], l, mid, k) : Add(rson[t], mid + 1, r, k);
  }
  int Merge(int u, int v, int l, int r) {
    if (!u || !v) return u | v;
    if (l == r) return sz[++tot] = sz[u] + sz[v], tot;
    int mid = l + r >> 1, cur = ++tot;
    sz[cur] = sz[u] + sz[v];
    lson[cur] = Merge(lson[u], lson[v], l, mid);
    rson[cur] = Merge(rson[u], rson[v], mid + 1, r);
    return cur;
  }
  int Find(int t, int l, int r, int x, int y) {
    if (!t) return 0;
    if (l == r) return l;
    int mid = l + r >> 1;
    if (x <= l && r <= y)
      return sz[lson[t]] ? Find(lson[t], l, mid, x, y)
                         : Find(rson[t], mid + 1, r, x, y);
    int d = 0;
    if (x <= mid && (d = Find(lson[t], l, mid, x, y))) return d;
    if (y > mid && (d = Find(rson[t], mid + 1, r, x, y))) return d;
    return 0;
  }
} tr;
int ans1, ans2, Len, L, R;
struct SAM {
  struct State {
    int next[26], len, link;
  };
  State st[200000 << 1];
  int sz, last;
  SAM() { sz = last = 0, st[0].len = 0, st[0].link = -1; }
  void Extend(char c, int endpos) {
    int cur = ++sz, p = last, c0 = c - 'a';
    st[cur].len = st[p].len + 1;
    tr.Add(rt[cur], 1, n, endpos);
    while (p >= 0 && !st[p].next[c0]) st[p].next[c0] = cur, p = st[p].link;
    if (p < 0)
      st[cur].link = 0;
    else {
      int q = st[p].next[c0];
      if (st[p].len + 1 == st[q].len)
        st[cur].link = q;
      else {
        int clone = ++sz;
        st[clone] = st[q], st[clone].len = st[p].len + 1;
        while (p >= 0 && st[p].next[c0] == q)
          st[p].next[c0] = clone, p = st[p].link;
        st[cur].link = st[q].link = clone;
      }
    }
    last = cur;
  }
  int d[200000 << 1], sta[200000 << 1];
  void Build_ep() {
    for (int i = 1; i <= sz; i++) ++d[st[i].link];
    int t = 0;
    for (int i = 1; i <= sz; i++)
      if (!d[i]) sta[++t] = i;
    for (int h = 0, x = 0; h++ < t;) {
      if (!--d[st[x = sta[h]].link]) sta[++t] = st[x].link;
      rt[st[x].link] = tr.Merge(rt[st[x].link], rt[x], 1, n);
    }
  }
  bool Find(int u, int c0, int k) {
    if (c0 > 25) return 0;
    int v = 0;
    for (int i = c0; i <= 25; i++)
      if (st[u].next[i]) {
        v = st[u].next[i];
        if (tr.Find(rt[v], 1, n, L + k, R)) return ans1 = k, ans2 = i, 1;
      }
    return 0;
  }
  bool Solve(int u, int k) {
    if (u && !tr.Find(rt[u], 1, n, L + k - 1, R)) return 0;
    if (k == Len) return Find(u, 0, k);
    if (k == R - L) return Find(u, ch[k + 1] - 'a' + 1, k);
    int v = st[u].next[ch[k + 1] - 'a'];
    if (v && Solve(v, k + 1)) return 1;
    return Find(u, ch[k + 1] - 'a' + 1, k);
  }
} sam;
int main() {
  scanf("%s\n", ch + 1);
  n = strlen(ch + 1);
  read(m);
  for (int i = 1; i <= n; i++) sam.Extend(ch[i], i);
  sam.Build_ep();
  for (int Case = 1; Case <= m; Case++) {
    read(L), read(R), scanf("%s\n", ch + 1);
    ans1 = ans2 = 0, Len = strlen(ch + 1);
    if (!sam.Solve(0, 0))
      puts("-1");
    else {
      for (int i = 1; i <= ans1; i++) putchar(ch[i]);
      putchar((char)ans2 + 'a');
      puts("");
    }
  }
  return 0;
}