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 maxn = 4e5 + 10;
const int N = 200000 * 20;
const int mod = 1e9 + 7;
int sum[N], ls[N], rs[N], rt[N], num;
void push_up(int root) { sum[root] = sum[ls[root]] + sum[rs[root]]; }
void add(int &root, int l, int r, int index) {
  if (l > index || r < index) return;
  if (!root) root = ++num;
  if (l == r && l == index) {
    sum[root] = 1;
    return;
  }
  int mid = l + r >> 1;
  add(ls[root], l, mid, index);
  add(rs[root], mid + 1, r, index);
  push_up(root);
}
int ask(int &root, int l, int r, int L, int R) {
  if (l > R || r < L) return 0;
  if (!root) return 0;
  if (l >= L && r <= R) return sum[root];
  int mid = l + r >> 1;
  return ask(ls[root], l, mid, L, R) + ask(rs[root], mid + 1, r, L, R);
}
int merge(int x, int y, int l, int r) {
  if (!x || !y) return x | y;
  if (l == r) {
    sum[x] |= sum[y];
    return x;
  }
  int mid = l + r >> 1, p = ++num;
  ls[p] = merge(ls[x], ls[y], l, mid);
  rs[p] = merge(rs[x], rs[y], mid + 1, r);
  push_up(p);
  return p;
}
int zi[maxn][27], fa[maxn], len[maxn], id = 1, las = 1, n;
char a[maxn];
void insert(int c) {
  int p = las, np = ++id;
  las = id;
  len[np] = len[p] + 1;
  for (; p && zi[p][c] == 0; p = fa[p]) zi[p][c] = np;
  if (p == 0)
    fa[np] = 1;
  else {
    int q = zi[p][c];
    if (len[q] == len[p] + 1)
      fa[np] = q;
    else {
      int nq = ++id;
      memcpy(zi[nq], zi[q], sizeof zi[nq]);
      fa[nq] = fa[q], len[nq] = len[p] + 1;
      fa[np] = fa[q] = nq;
      for (; p && zi[p][c] == q; p = fa[p]) zi[p][c] = nq;
    }
  }
  add(rt[np], 1, n, len[np]);
}
vector<int> vec[maxn];
void dfs(int u) {
  for (auto v : vec[u]) {
    dfs(v);
    rt[u] = merge(rt[u], rt[v], 1, n);
  }
}
int ans[maxn], now[maxn];
void search() {
  int l, r, i = 1, p = 1, le = 0;
  cin >> l >> r;
  scanf("%s", a + 1), le = strlen(a + 1);
  for (;; i++) {
    ans[i] = -1;
    for (int j = max(0, a[i] - 'a' + 1); j < 26; j++)
      if (zi[p][j] && ask(rt[zi[p][j]], 1, n, l + i - 1, r)) {
        ans[i] = j;
        break;
      }
    if (i == le + 1) break;
    p = zi[p][a[i] - 'a'];
    if (!p || !ask(rt[p], 1, n, l - i + 1, r)) break;
  }
  while (i && ans[i] == -1) i--;
  if (!i)
    puts("-1");
  else {
    for (int j = 1; j < i; j++) printf("%c", a[j]);
    printf("%c\n", ans[i] + 'a');
  }
}
signed main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  for (int i = 1; i <= n; i++) insert(a[i] - 'a');
  for (int i = 2; i <= id; i++) vec[fa[i]].push_back(i);
  dfs(1);
  int q;
  cin >> q;
  while (q--) {
    int L, R;
    scanf("%d%d%s", &L, &R, a + 1);
    int le = strlen(a + 1), p = 1, top = 0;
    now[0] = 1;
    for (int i = 1; i <= le; i++) {
      int v = zi[p][a[i] - 'a'];
      if (v && ask(rt[v], 1, n, L + i - 1, R))
        ans[++top] = a[i] - 'a', now[top] = p = zi[p][a[i] - 'a'];
      else
        break;
    }
    if (top == le) a[top + 1] = 'a' - 1;
    for (; top >= 0; top--) {
      int flag = 0;
      for (int j = a[top + 1] - 'a' + 1; j <= 25; j++) {
        int v = zi[now[top]][j];
        if (v && ask(rt[v], 1, n, L + top, R)) {
          ans[++top] = j;
          flag = 1;
          break;
        }
      }
      if (flag) break;
    }
    if (top == -1)
      printf("-1\n");
    else {
      for (int i = 1; i <= top; i++) cout << char(ans[i] + 'a');
      cout << "\n";
    }
  }
}