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 = 100010;
char s[N];
int n;
int lst, rt, cnt, son[N << 1][26], par[N << 1], root[N << 1];
int sum[8000010], ls[8000010], rs[8000010], tot, len[N << 1];
void insert(int& p, int l, int r, int v, int t) {
  if (!p) p = ++tot;
  sum[p] += t;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (v <= mid)
    insert(ls[p], l, mid, v, t);
  else
    insert(rs[p], mid + 1, r, v, t);
}
int merge(int u, int v) {
  if (!u || !v) return u + v;
  int p = ++tot;
  sum[p] = sum[u] + sum[v];
  ls[p] = merge(ls[u], ls[v]);
  rs[p] = merge(rs[u], rs[v]);
  return p;
}
int qry(int p, int l, int r, int L, int R) {
  if ((!p) || (L <= l && r <= R)) return sum[p];
  int mid = (l + r) >> 1, res = 0;
  if (L <= mid) res += qry(ls[p], l, mid, L, R);
  if (R > mid) res += qry(rs[p], mid + 1, r, L, R);
  return res;
}
int copy(int x) {
  ++cnt;
  memcpy(son[cnt], son[x], sizeof(son[x]));
  par[cnt] = par[x];
  return cnt;
}
void extend(int c, int num) {
  int p = lst, u = ++cnt;
  len[u] = len[p] + 1;
  insert(root[u], 1, n, num, 1);
  for (; p && !son[p][c]; p = par[p]) son[p][c] = u;
  if (!p)
    par[u] = rt;
  else {
    int to = son[p][c];
    if (len[to] == len[p] + 1)
      par[u] = to;
    else {
      int cto = copy(to);
      len[cto] = len[p] + 1;
      par[to] = par[u] = cto;
      for (; p && son[p][c] == to; p = par[p]) son[p][c] = cto;
    }
  }
  lst = u;
}
vector<int> g[N << 1];
void dfs(int u, int pre) {
  for (int i = 0; i < g[u].size(); ++i) {
    if (g[u][i] == pre) continue;
    dfs(g[u][i], u);
    root[u] = merge(root[u], root[g[u][i]]);
  }
}
int q, fuck[N << 1];
char t[N << 1];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  rt = lst = cnt = 1;
  for (int i = 1; i <= n; ++i) extend(s[i] - 'a', i);
  for (int i = 2; i <= cnt; ++i) g[par[i]].push_back(i);
  dfs(1, 0);
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    scanf("%s", t + 1);
    int len = strlen(t + 1);
    int cur = rt, match = 0;
    int i;
    for (i = 1; i <= len; ++i) {
      if (son[cur][t[i] - 'a'])
        fuck[son[cur][t[i] - 'a']] = cur, cur = son[cur][t[i] - 'a'], ++match;
      else
        break;
    }
    t[len + 1] = 'a' - 1;
    ++match;
    for (; cur; cur = fuck[cur]) {
      int pos = t[i] - 'a';
      for (int k = pos + 1; k < 26; ++k)
        if (son[cur][k] &&
            qry(root[son[cur][k]], 1, n, l + match - 1, r) != 0) {
          for (int j = 1; j < match; ++j) putchar(t[j]);
          putchar(k + 'a');
          puts("");
          goto end;
        }
      --match;
      --i;
    }
    puts("-1");
  end:;
  }
  return 0;
}