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 = 200200;
struct SAM {
  int len, slink, trans[26];
} t[MAXN];
int top = 1, las = 1;
void extend(int c) {
  int now = ++top, i;
  t[now].len = t[las].len + 1;
  for (i = las; i && !t[i].trans[c]; i = t[i].slink) t[i].trans[c] = now;
  las = now;
  if (!i) {
    t[now].slink = 1;
    return;
  }
  int rua = t[i].trans[c];
  if (t[rua].len == t[i].len + 1) {
    t[now].slink = rua;
    return;
  }
  int cl = ++top;
  t[cl] = t[rua];
  t[cl].len = t[i].len + 1;
  for (i; i && t[i].trans[c] == rua; i = t[i].slink) t[i].trans[c] = cl;
  t[rua].slink = t[now].slink = cl;
}
char s[MAXN], tmp[MAXN];
vector<int> E[MAXN];
namespace seg {
struct node {
  int ls, rs, val;
} t[MAXN << 5];
int top;
void pushup(int x) { t[x].val = t[t[x].ls].val + t[t[x].rs].val; }
void modify(int pos, int k, int L, int R, int &x) {
  int prex = x;
  x = ++top;
  t[x] = t[prex];
  if (L == R) {
    t[x].val += k;
    return;
  }
  int mid = (L + R) >> 1;
  if (pos <= mid)
    modify(pos, k, L, mid, t[x].ls);
  else
    modify(pos, k, mid + 1, R, t[x].rs);
  pushup(x);
}
int query(int l, int r, int L, int R, int x) {
  if (!x) return 0;
  if (l <= L && R <= r) return t[x].val;
  int mid = (L + R) >> 1, ret = 0;
  if (l <= mid) ret += query(l, r, L, mid, t[x].ls);
  if (mid < r) ret += query(l, r, mid + 1, R, t[x].rs);
  return ret;
}
int merge(int x, int y, int L, int R) {
  if (!x || !y) return x | y;
  int ret = ++top, mid = (L + R) >> 1;
  if (L == R) {
    t[ret].val = t[x].val | t[y].val;
    return ret;
  }
  t[ret].ls = merge(t[x].ls, t[y].ls, L, mid);
  t[ret].rs = merge(t[x].rs, t[y].rs, mid + 1, R);
  pushup(ret);
  return ret;
}
}  // namespace seg
int rt[MAXN], n;
void dfs(int x) {
  if (!rt[x]) rt[x] = ++seg::top;
  for (auto i : E[x]) {
    dfs(i);
    rt[x] = seg::merge(rt[x], rt[i], 1, n);
  }
}
bool check(int l, int r, int len, int x) {
  return seg::query(l + len - 1, r, 1, n, rt[x]);
}
char ans[MAXN];
int solve(int l, int r, char *s, int len, int now, int olen) {
  if (len && t[now].trans[s[0] - 'a'] &&
      check(l, r, olen - len + 1, t[now].trans[s[0] - 'a'])) {
    int res = solve(l, r, s + 1, len - 1, t[now].trans[s[0] - 'a'], olen);
    if (res != -1) {
      ans[len] = s[0];
      return res;
    }
  }
  for (int i = len ? (s[0] - 'a' + 1) : 0; i < 26; i++)
    if (t[now].trans[i] && check(l, r, olen - len + 1, t[now].trans[i])) {
      ans[len] = i + 'a';
      return len;
    }
  return -1;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  int i, j;
  rt[1] = ++seg::top;
  for (i = 1; i <= n; i++) extend(s[i] - 'a'), seg::modify(i, 1, 1, n, rt[las]);
  for (i = 2; i <= top; i++) E[t[i].slink].push_back(i);
  dfs(1);
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int l, r;
    scanf("%d%d%s", &l, &r, tmp + 1);
    int len = strlen(tmp + 1);
    int res = solve(l, r, tmp + 1, len, 1, len);
    if (res == -1)
      puts("-1");
    else {
      for (i = len; i >= res; i--) putchar(ans[i]);
      puts("");
    }
  }
  return 0;
}