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 = 200050;
inline int read() {
  char ch;
  while ((ch = getchar()) < '0' || ch > '9')
    ;
  int res = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + ch - '0';
  return res;
}
char s[N >> 1], t;
int tot, rt[N], lst, n, pre[N], qlm[N], len[N], tar[N][28];
struct node {
  int ls, rs;
} d[N * 42];
struct Seg {
  int rnm;
  void modify(int &k, int l, int r, int x) {
    if (!k) k = ++rnm;
    if (l == r) return;
    int mid = l + r >> 1;
    if (x <= mid)
      modify(d[k].ls, l, mid, x);
    else
      modify(d[k].rs, mid + 1, r, x);
  }
  bool query(int k, int l, int r, int x, int y) {
    if (!k || l > y || r < x) return 0;
    if (l >= x && r <= y) return 1;
    int mid = l + r >> 1;
    if (query(d[k].ls, l, mid, x, y)) return 1;
    if (query(d[k].rs, mid + 1, r, x, y)) return 1;
    return 0;
  }
  int mrge(int k1, int k2) {
    if (!k1 || !k2) return k1 | k2;
    int now = ++rnm;
    d[now].ls = mrge(d[k1].ls, d[k2].ls);
    d[now].rs = mrge(d[k1].rs, d[k2].rs);
    return now;
  }
} T;
int node(int l) {
  len[++tot] = l;
  return tot;
}
void ins(int c) {
  int i = lst;
  lst = node(len[i] + 1);
  qlm[lst] = 1;
  while (!tar[i][c]) {
    tar[i][c] = lst;
    if (!(i = pre[i])) return void(pre[lst] = 1);
  }
  int rtm = tar[i][c];
  if (len[rtm] == len[i] + 1) return void(pre[lst] = rtm);
  int gnn = node(len[i] + 1);
  pre[gnn] = pre[rtm];
  pre[rtm] = pre[lst] = gnn;
  memcpy(tar[gnn], tar[rtm], sizeof(tar[0]));
  do {
    tar[i][c] = gnn;
    i = pre[i];
  } while (i && tar[i][c] == rtm);
}
vector<int> G[N];
void dfs(int u) {
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    dfs(v);
    rt[u] = T.mrge(rt[u], rt[v]);
  }
  if (qlm[u]) T.modify(rt[u], 1, n, len[u]);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  lst = tot = 1;
  for (int i = 1; i <= n; i++) ins(s[i] - 'a');
  for (int i = 2; i <= tot; i++) G[pre[i]].push_back(i);
  dfs(1);
  int q = read(), l, r;
  while (q--) {
    l = read();
    r = read();
    scanf("%s", s + 1);
    int pos = -1, u = 1, m = strlen(s + 1);
    s[++m] = 'a' - 1;
    for (int i = 1; i <= m; i++) {
      int c = s[i] - 'a';
      for (int j = c + 1; j < 26; j++)
        if (tar[u][j] && T.query(rt[tar[u][j]], 1, n, l + i - 1, r)) {
          pos = i;
          t = 'a' + j;
          break;
        }
      if (i == m || !tar[u][c] || !T.query(rt[tar[u][c]], 1, n, l + i - 1, r))
        break;
      u = tar[u][c];
    }
    if (pos == -1)
      printf("-1\n");
    else {
      for (int i = 1; i < pos; i++) printf("%c", s[i]);
      printf("%c\n", t);
    }
  }
  return 0;
}