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;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, m, cnt, h[400005], arr[400005], root[400005];
char s[400005];
struct Edge {
  int to, next;
} a[400005 * 2];
void Add(int x, int y) {
  cnt++;
  a[cnt].to = y;
  a[cnt].next = h[x];
  h[x] = cnt;
}
struct SegTree {
  int all, lc[400005 << 5], rc[400005 << 5];
  int Merge(int x, int y) {
    if (!x || !y) return x + y;
    int v = ++all;
    lc[v] = Merge(lc[x], lc[y]);
    rc[v] = Merge(rc[x], rc[y]);
    return v;
  }
  void Modify(int l, int r, int pos, int &rt) {
    rt = ++all;
    if (l == r) return;
    int mid = l + r >> 1;
    if (pos <= mid)
      Modify(l, mid, pos, lc[rt]);
    else
      Modify(mid + 1, r, pos, rc[rt]);
  }
  void Build(int x) {
    for (int i = h[x]; i; i = a[i].next) {
      int y = a[i].to;
      Build(y);
    }
    if (!root[x]) root[x] = ++all;
    for (int i = h[x]; i; i = a[i].next)
      root[x] = Merge(root[x], root[a[i].to]);
  }
  bool Ask(int l, int r, int L, int R, int v) {
    if (!v) return 0;
    if (L <= l && r <= R) return 1;
    int mid = l + r >> 1;
    if (mid >= L && Ask(l, mid, L, R, lc[v])) return 1;
    if (mid + 1 <= R && Ask(mid + 1, r, L, R, rc[v])) return 1;
    return 0;
  }
} tr;
struct SAM {
  int all, last, len[400005], link[400005], c[400005][26];
  long long f[400005];
  SAM() : all(0), last(0) { link[0] = -1; }
  void attend(int x) {
    int cur = ++all, p = last;
    last = cur;
    len[cur] = len[p] + 1;
    tr.Modify(1, n, len[cur], root[cur]);
    while (~p && !c[p][x]) c[p][x] = cur, p = link[p];
    if (p == -1)
      link[cur] = 0;
    else {
      int q = c[p][x], u;
      if (len[p] + 1 == len[q])
        link[cur] = q;
      else {
        len[u = ++all] = len[p] + 1;
        memcpy(c[u], c[q], sizeof(c[q]));
        link[u] = link[q];
        link[q] = link[cur] = u;
        while (~p && c[p][x] == q) c[p][x] = u, p = link[p];
      }
    }
  }
  void Link() {
    for (int i = 1; i <= all; ++i) Add(link[i], i);
  }
  void deal(int l, int r) {
    int now = 0, len = strlen(s + 1), last = len + 1;
    s[len + 1] = 'a' - 1;
    for (int i = 1; i <= len + 1; ++i) {
      arr[i] = -1;
      for (int j = s[i] - 'a' + 1; j < 26; ++j) {
        int y = c[now][j];
        if (y && tr.Ask(1, n, l + i - 1, r, root[y])) {
          arr[i] = j;
          break;
        }
      }
      now = c[now][s[i] - 'a'];
      if (!now || (now && !tr.Ask(1, n, l + i - 1, r, root[now]))) {
        last = i;
        break;
      }
    }
    while (last && arr[last] == -1) last--;
    if (!last)
      puts("-1");
    else {
      for (int i = 1; i < last; ++i) putchar(s[i]);
      putchar(arr[last] + 'a');
      putchar('\n');
    }
  }
} sam;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) sam.attend(s[i] - 'a');
  sam.Link();
  tr.Build(0);
  m = read();
  while (m--) {
    int l = read(), r = read();
    scanf("%s", s + 1);
    sam.deal(l, r);
  }
}