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 N = 3e5 + 10, M = N * 30;
int n, Q, m, lst = 1, cnt = 1, idx;
int ch[N][26], rt[N], fa[N], len[N];
int sz[M], ls[M], rs[M];
char s[N], t[N];
vector<int> g[N];
void upd(int x) { sz[x] = sz[ls[x]] + sz[rs[x]]; }
void modify(int &x, int l, int r, int pos) {
  if (!x) x = ++idx;
  if (l == r) {
    sz[x] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    modify(ls[x], l, mid, pos);
  else
    modify(rs[x], mid + 1, r, pos);
  upd(x);
}
void insert(int c, int id) {
  int p = lst, np = lst = ++cnt;
  len[np] = len[p] + 1;
  for (; p && !ch[p][c]; p = fa[p]) ch[p][c] = np;
  if (!p)
    fa[np] = 1;
  else {
    int q = ch[p][c];
    if (len[q] == len[p] + 1)
      fa[np] = q;
    else {
      int nq = ++cnt;
      len[nq] = len[p] + 1;
      memcpy(ch[nq], ch[q], sizeof(ch[nq]));
      fa[nq] = fa[q];
      fa[q] = fa[np] = nq;
      for (; p && ch[p][c] == q; p = fa[p]) ch[p][c] = nq;
    }
  }
  modify(rt[np], 1, n, id);
}
int merge(int x, int y, int l, int r) {
  if (!x || !y) return x | y;
  int mid = (l + r) >> 1, o = ++idx;
  if (l == r)
    sz[o] = sz[x] + sz[y];
  else {
    ls[o] = merge(ls[x], ls[y], l, mid);
    rs[o] = merge(rs[x], rs[y], mid + 1, r);
    sz[o] = sz[ls[o]] + sz[rs[o]];
  }
  return o;
}
void dfs(int x, int fa) {
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    if (y == fa) continue;
    dfs(y, x);
    rt[x] = merge(rt[x], rt[y], 1, n);
  }
}
int query(int x, int l, int r, int lx, int rx) {
  if (!x) return 0;
  if (lx <= l && r <= rx) return sz[x];
  int mid = (l + r) >> 1, ret = 0;
  if (lx <= mid) ret += query(ls[x], l, mid, lx, rx);
  if (rx > mid) ret += query(rs[x], mid + 1, r, lx, rx);
  return ret;
}
void solve(char t[], int l, int r) {
  int len = strlen(t + 1), res = -1, pos = 0, p = 1;
  for (int i = 1; i <= len + 1; i++) {
    int c = (i > len ? -1 : t[i] - 'a');
    for (int j = c + 1; j <= 25; j++)
      if (ch[p][j]) {
        if (query(rt[ch[p][j]], 1, n, l + i - 1, r)) {
          pos = i - 1, res = j;
          break;
        }
      }
    if (c != -1 && ch[p][c])
      p = ch[p][c];
    else
      break;
  }
  if (res == -1) {
    puts("-1");
    return;
  }
  for (int i = 1; i <= pos; i++) printf("%c", t[i]);
  printf("%c\n", res + 'a');
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) insert(s[i] - 'a', i);
  for (int i = 2; i <= cnt; i++) g[fa[i]].push_back(i);
  dfs(1, 0);
  cin >> Q;
  while (Q--) {
    int l, r;
    scanf("%d%d%s", &l, &r, t + 1);
    solve(t, l, r);
  }
  return 0;
}