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>
int rd() {
  int k = 0;
  char c = getchar();
  while (c > '9' || c < '0') c = getchar();
  while (c >= '0' && c <= '9') k = k * 10 + c - 48, c = getchar();
  return k;
}
const int N = 100001, M = N << 1;
int n, m, u, T, L, R, ans[N];
char s[N], c[N];
int Max(int x, int y) { return x > y ? x : y; }
namespace sg {
int pn;
struct T {
  int l, r;
} t[M << 5];
void Insert(int& x, int l, int r, int w) {
  t[++pn] = t[x], x = pn;
  if (l == r) return;
  int p = (l + r) >> 1;
  if (w <= p)
    Insert(t[x].l, l, p, w);
  else
    Insert(t[x].r, p + 1, r, w);
}
void Merge(int& x, int y, int l, int r) {
  if (!x || !y) {
    x |= y;
    return;
  }
  t[++pn] = t[x], x = pn;
  if (l != r) {
    int p = (l + r) >> 1;
    Merge(t[x].l, t[y].l, l, p), Merge(t[x].r, t[y].r, p + 1, r);
  }
}
bool Query(int x, int l, int r, int L, int R) {
  if (!x || L > R) return 0;
  if (L <= l && r <= R) return 1;
  int p = (l + r) >> 1;
  return L <= p && Query(t[x].l, l, p, L, R) ||
         p < R && Query(t[x].r, p + 1, r, L, R);
}
};  // namespace sg
struct SAM {
  int pn, tn, en, head[M], rt[M];
  struct E {
    int v, nxt;
  } e[M];
  struct T {
    int f, s[26], len, v;
  } t[M];
  SAM() { pn = tn = 1; }
  void add(int u, int v) { e[++en].v = v, e[en].nxt = head[u], head[u] = en; }
  void dfs(int u) {
    if (t[u].v) sg::Insert(rt[u], 1, n, t[u].v);
    for (int i = head[u]; i; i = e[i].nxt)
      dfs(e[i].v), sg::Merge(rt[u], rt[e[i].v], 1, n);
  }
  void Make() {
    for (int i = 2; i <= pn; ++i) add(t[i].f, i);
  }
  void Insert(int c) {
    int np = ++pn, p = tn;
    tn = pn, t[np].len = t[p].len + 1, t[np].v = n + 1;
    for (; p && !t[p].s[c]; p = t[p].f) t[p].s[c] = np;
    if (!p) {
      t[np].f = 1;
      return;
    }
    int q = t[p].s[c];
    if (t[q].len == t[p].len + 1) {
      t[np].f = q;
      return;
    }
    int nq = ++pn;
    t[nq] = t[q], t[nq].len = t[p].len + 1, t[q].f = t[np].f = nq, t[nq].v = 0;
    for (; p && t[p].s[c] == q; p = t[p].f) t[p].s[c] = nq;
  }
  bool Query(int u, int c, int l, int r) {
    return t[u].s[c] && sg::Query(rt[t[u].s[c]], 1, n, l, r);
  }
} sam;
int main() {
  scanf("%s", s), T = rd();
  for (; s[n] != '\0'; ++n) sam.Insert(s[n] - 'a');
  sam.Make(), sam.dfs(1);
  while (T--) {
    L = rd(), R = rd(), scanf("%s", c);
    for (m = 0, u = 1;; ++m) {
      ans[m] = -1;
      for (int i = Max(c[m] - 'a' + 1, 0); i < 26; ++i)
        if (sam.Query(u, i, L + m, R)) {
          ans[m] = i;
          break;
        }
      if (c[m] == '\0' || !sam.Query(u, c[m] - 'a', L + m, R)) break;
      u = sam.t[u].s[c[m] - 'a'];
    }
    while (m >= 0 && ans[m] < 0) --m;
    if (m < 0) {
      puts("-1");
      continue;
    }
    for (int i = 0; i < m; ++i) putchar(c[i]);
    putchar(ans[m] + 'a'), putchar('\n');
  }
  return 0;
}