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;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  return x;
}
const int N = 3e5 + 5;
struct TREE {
  int l, r, val;
} a[N << 4];
int rt[N << 1], tot;
int NEW() { return ++tot; }
void push_up(int o) { a[o].val = a[a[o].l].val + a[a[o].r].val; }
void upd(int& o, int l, int r, int pos, int k) {
  if (!o) o = NEW();
  if (l == r) {
    a[o].val += k;
    return;
  }
  int mid = l + r >> 1;
  if (mid >= pos)
    upd(a[o].l, l, mid, pos, k);
  else
    upd(a[o].r, mid + 1, r, pos, k);
  push_up(o);
}
int merge(int x, int y, int l, int r) {
  if (!x || !y) return x + y;
  if (l == r) {
    a[x].val += a[y].val;
    return x;
  }
  int mid = l + r >> 1, o = NEW();
  a[o].l = merge(a[x].l, a[y].l, l, mid);
  a[o].r = merge(a[x].r, a[y].r, mid + 1, r);
  push_up(o);
  return o;
}
int tr[N << 1][26], len[N << 1], fa[N << 1], cnt = 1, las = 1;
void cpy(int p, int q) {
  for (int i = 0; i < 26; i++) tr[p][i] = tr[q][i];
  fa[p] = fa[q];
}
void extend(int c, int pos) {
  int p = las, np;
  len[np = las = ++cnt] = len[p] + 1;
  for (; p && !tr[p][c]; p = fa[p]) tr[p][c] = np;
  if (!p)
    fa[np] = 1;
  else {
    int q = tr[p][c];
    if (len[q] == len[p] + 1)
      fa[np] = q;
    else {
      int nq = ++cnt;
      cpy(nq, q);
      len[nq] = len[p] + 1;
      fa[np] = fa[q] = nq;
      for (; tr[p][c] == q; p = fa[p]) tr[p][c] = nq;
    }
  }
  upd(rt[np], 1, N - 5, pos, 1);
}
struct EDGE {
  int to, next;
} edge[N << 2];
int num_edge, head[N << 1];
void add_edge(int from, int to) {
  edge[++num_edge].next = head[from];
  head[from] = num_edge;
  edge[num_edge].to = to;
}
void dfs(int u) {
  for (int i = head[u]; i; i = edge[i].next) {
    int v = edge[i].to;
    dfs(v);
    if (!rt[u]) rt[u] = NEW();
    rt[u] = merge(rt[u], rt[v], 1, N - 5);
  }
}
bool query(int o, int l, int r, int ll, int rr) {
  if (r < ll || l > rr) return 0;
  if (l >= ll && r <= rr) return a[o].val > 0;
  int mid = l + r >> 1;
  bool ret = 0;
  if (a[o].l) ret |= query(a[o].l, l, mid, ll, rr);
  if (ret) return 1;
  if (a[o].r) ret |= query(a[o].r, mid + 1, r, ll, rr);
  return ret;
}
int minn[N << 1], lth;
void solve(char* s, int l, int r) {
  int p = 1, i;
  lth = 0;
  for (i = 1; s[i]; i++) {
    minn[i] = -1;
    int v = tr[p][s[i] - 'a'];
    if (query(rt[v], 1, N - 5, l + i - 1, r)) {
      for (int j = s[i] - 'a' + 1; j < 26; j++)
        if (tr[p][j] && query(rt[tr[p][j]], 1, N - 5, l + i - 1, r)) {
          minn[i] = j;
          break;
        }
      p = v;
      lth++;
    } else
      break;
  }
  minn[i] = -1;
  for (int j = 0; j < 26; j++)
    if (j > s[i] - 'a' && tr[p][j] &&
        query(rt[tr[p][j]], 1, N - 5, l + i - 1, r)) {
      lth++, minn[i] = j;
      break;
    }
  for (i = lth; i >= 1; i--) {
    if (minn[i] > -1) break;
  }
  if (i < 1) {
    puts("-1");
    return;
  }
  for (int j = 1; j < i; j++) putchar(s[j]);
  putchar(minn[i] + 'a');
  puts("");
}
int m;
char ch[N];
int main() {
  scanf("%s", ch + 1);
  for (int i = 1; ch[i]; i++) extend(ch[i] - 'a', i);
  for (int i = 2; i <= cnt; i++) add_edge(fa[i], i);
  dfs(1);
  m = read();
  while (m--) {
    int l = read(), r = read();
    scanf("%s", ch + 1);
    solve(ch, l, r);
  }
  return 0;
}