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 = 2e5 + 5;
const int mod = 1e9 + 7;
struct SAM {
  int n, tot, last;
  int ch[N][26], dep[N], fa[N];
  int root[N], ls[N * 20], rs[N * 20], cnt;
  vector<int> G[N];
  void init() {
    tot = last = 1;
    memset(ch[1], 0, sizeof(ch[1]));
  }
  inline int newnode(int _dep) {
    dep[++tot] = _dep;
    memset(ch[tot], 0, sizeof(ch[tot]));
    return tot;
  }
  void add(int alp) {
    ++n;
    alp -= 'a';
    int u, p = newnode(dep[last] + 1);
    for (u = last; u && !ch[u][alp]; u = fa[u]) ch[u][alp] = p;
    if (!u)
      fa[p] = 1;
    else {
      int v = ch[u][alp];
      if (dep[v] == dep[u] + 1)
        fa[p] = v;
      else {
        int nv = newnode(dep[u] + 1);
        fa[nv] = fa[v];
        fa[v] = fa[p] = nv;
        memcpy(ch[nv], ch[v], sizeof(ch[v]));
        for (; u && ch[u][alp] == v; u = fa[u]) ch[u][alp] = nv;
      }
    }
    last = p;
  }
  int build(int l, int r, int p) {
    if (l == r) return ++cnt;
    int mid = l + r >> 1;
    int now = ++cnt;
    if (p <= mid)
      ls[now] = build(l, mid, p);
    else
      rs[now] = build(mid + 1, r, p);
    return now;
  }
  int merge(int x, int y) {
    if (x == 0 || y == 0) return x + y;
    int now = ++cnt;
    ls[now] = merge(ls[x], ls[y]);
    rs[now] = merge(rs[x], rs[y]);
    return now;
  }
  void dfs(int x) {
    for (int i = 0; i < G[x].size(); ++i) {
      int u = G[x][i];
      dfs(u);
      root[x] = merge(root[x], root[u]);
    }
  }
  void build_segtree(char* s) {
    int now = 1;
    int n = strlen(s + 1);
    for (int i = 1; i <= n; ++i) {
      now = ch[now][s[i] - 'a'];
      root[now] = build(1, n, i);
    }
    for (int i = 1; i <= tot; ++i) G[fa[i]].push_back(i);
    dfs(1);
  }
  string ans;
  bool chk(int k, int l, int r, int p, int q) {
    if (k == 0) return false;
    if (l >= p && r <= q) return true;
    if (l > q || r < p) return false;
    int mid = l + r >> 1;
    return chk(ls[k], l, mid, p, q) || chk(rs[k], mid + 1, r, p, q);
  }
  bool check(int l, int r, int p) { return chk(p, 1, n, l, r); }
  bool solve(int now, int l, int r, char* s) {
    if (l > r) return false;
    if (*s == 0) {
      for (int i = 0; i < 26; i++) {
        if (ch[now][i] && check(l, r, root[ch[now][i]])) {
          ans.push_back('a' + i);
          return true;
        }
      }
      return false;
    } else {
      int i = *s - 'a';
      if (ch[now][i] && check(l, r, root[ch[now][i]]) &&
          solve(ch[now][i], l + 1, r, s + 1)) {
        ans.push_back('a' + i);
        return true;
      }
      for (i = i + 1; i < 26; ++i) {
        if (ch[now][i] && check(l, r, root[ch[now][i]])) {
          ans.push_back('a' + i);
          return true;
        }
      }
      return false;
    }
  }
} sam;
int n, m;
char s[N];
int main() {
  sam.init();
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) sam.add(s[i]);
  sam.build_segtree(s);
  scanf("%d", &m);
  while (m--) {
    int l, r;
    scanf("%d %d %s", &l, &r, s + 1);
    sam.ans.clear();
    if (!sam.solve(1, l, r, s + 1))
      printf("-1\n");
    else {
      reverse(sam.ans.begin(), sam.ans.end());
      printf("%s\n", sam.ans.c_str());
    }
  }
}