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;
namespace SAM {
int len[200005], link[200005], nxt[200005][26], V, lst;
void init() {
  memset(nxt, 0, sizeof(nxt));
  V = lst = 1;
  len[1] = link[1] = 0;
}
void append(char c) {
  c -= 'a';
  int p = lst, cur = ++V;
  len[cur] = len[p] + 1;
  while (p && !nxt[p][c]) {
    nxt[p][c] = cur;
    p = link[p];
  }
  if (!p) {
    link[cur] = 1;
  } else {
    int q = nxt[p][c];
    if (len[p] + 1 == len[q]) {
      link[cur] = q;
    } else {
      int tmp = ++V;
      for (int i = 0; i < 26; i++) nxt[tmp][i] = nxt[q][i];
      len[tmp] = len[p] + 1;
      link[tmp] = link[q];
      while (p && nxt[p][c] == q) {
        nxt[p][c] = tmp;
        p = link[p];
      }
      link[q] = link[cur] = tmp;
    }
  }
  lst = cur;
}
void print() {
  for (int i = 1; i <= V; i++) {
    cout << "node " << i << ": ";
    cout << "len: " << len[i] << ", link: " << link[i] << endl;
    for (int j = 0; j < 26; j++) {
      if (nxt[i][j]) {
        cout << char(j + 'a') << " " << nxt[i][j] << endl;
      }
    }
    system("pause");
  }
}
}  // namespace SAM
namespace Tree {
vector<int> adj[200005];
void build() {
  for (int i = 2; i <= SAM::V; i++) {
    adj[SAM::link[i]].push_back(i);
  }
}
int dfn[200005], ed[200005], ind;
void dfs(int u) {
  dfn[u] = ++ind;
  for (auto v : adj[u]) dfs(v);
  ed[u] = ind;
}
}  // namespace Tree
namespace Sgt {
int maxi[200005 << 2];
void update(int id, int l, int r, int pos, int x) {
  if (l == r) {
    maxi[id] = x;
  } else {
    int mid = (l + r) >> 1;
    if (pos <= mid)
      update(id << 1, l, mid, pos, x);
    else
      update(id << 1 | 1, mid + 1, r, pos, x);
    maxi[id] = max(maxi[id << 1], maxi[id << 1 | 1]);
  }
}
int query(int id, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return maxi[id];
  int mid = (l + r) >> 1, res = 0;
  if (ql <= mid) res = max(res, query(id << 1, l, mid, ql, qr));
  if (mid < qr) res = max(res, query(id << 1 | 1, mid + 1, r, ql, qr));
  return res;
}
}  // namespace Sgt
bool able(int u, int l, int ql, char c) {
  c -= 'a';
  int v = SAM::nxt[u][c];
  if (!v) return false;
  return Sgt::query(1, 1, SAM::V, Tree::dfn[v], Tree::ed[v]) - ql + 1 > l;
}
char s[100005], t[400005], *tail = t;
int n, q;
string ans[200005];
struct Query {
  int l, r, id;
  char* str;
  bool operator<(const Query& b) const { return r < b.r; }
} qs[200005];
bool dfs(int id, int u, int i) {
  for (char c = max(qs[id].str[i], 'a'); c <= 'z'; c++) {
    if (able(u, i - 1, qs[id].l, c)) {
      ans[qs[id].id].push_back(c);
      if (c > qs[id].str[i] || dfs(id, SAM::nxt[u][c - 'a'], i + 1))
        return true;
      ans[qs[id].id].pop_back();
    }
  }
  return false;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  SAM::init();
  for (int i = 1; i <= n; i++) SAM::append(s[i]);
  Tree::build();
  Tree::dfs(1);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%s", &qs[i].l, &qs[i].r, tail + 1);
    int tmp = strlen(tail + 1);
    qs[i].str = tail;
    qs[i].id = i;
    tail += tmp + 1;
  }
  sort(qs + 1, qs + q + 1);
  int j = 0, u = 1;
  for (int i = 1; i <= q; i++) {
    while (j < qs[i].r) {
      j++;
      u = SAM::nxt[u][s[j] - 'a'];
      Sgt::update(1, 1, SAM::V, Tree::dfn[u], j);
    }
    dfs(i, 1, 1);
  }
  for (int i = 1; i <= q; i++) {
    if (ans[i].empty())
      puts("-1");
    else
      printf("%s\n", ans[i].c_str());
  }
  return 0;
}