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 maxn = 401000;
char s[maxn];
int n, m, npos[maxn];
inline int read() {
  int res = 0;
  char ch = getchar(), ch2 = ch;
  while (!isdigit(ch)) ch2 = ch, ch = getchar();
  while (isdigit(ch)) res = (res << 3) + (res << 1) + ch - '0', ch = getchar();
  return ch2 == '-' ? -res : res;
}
struct Segment_Tree {
  int rt[maxn], verx;
  int son[2][maxn << 5];
  void modify(int &p, int pos, int l, int r) {
    p = ++verx;
    if (l == r) return;
    if (pos <= ((l + r) >> 1))
      modify(son[0][p], pos, l, ((l + r) >> 1));
    else
      modify(son[1][p], pos, ((l + r) >> 1) + 1, r);
  }
  int merge(int x, int y, int l, int r) {
    if (!x || !y || l == r) return x | y;
    int p = ++verx;
    son[0][p] = merge(son[0][x], son[0][y], l, ((l + r) >> 1));
    son[1][p] = merge(son[1][x], son[1][y], ((l + r) >> 1) + 1, r);
    return p;
  }
  bool query(int p, int lr, int rr, int l, int r) {
    if (lr > r || l > rr || !p) return false;
    if (lr <= l && r <= rr) return true;
    if (lr <= ((l + r) >> 1) && query(son[0][p], lr, rr, l, ((l + r) >> 1)))
      return true;
    if (rr > ((l + r) >> 1) && query(son[1][p], lr, rr, ((l + r) >> 1) + 1, r))
      return true;
    return false;
  }
} Q;
struct SAM {
  int ver, last;
  int len[maxn], nxt[26][maxn], link[maxn];
  vector<int> v[maxn];
  void reset() {
    ver = last = 1;
    len[1] = 0;
    link[1] = 0;
  }
  void insert(int c) {
    int cur = ++ver;
    len[cur] = len[last] + 1;
    Q.modify(Q.rt[cur], len[cur], 1, n);
    int p = last;
    while (p && !nxt[c][p]) {
      nxt[c][p] = cur;
      p = link[p];
    }
    if (!p)
      link[cur] = 1;
    else {
      int q = nxt[c][p];
      if (len[q] == len[p] + 1)
        link[cur] = q;
      else {
        int clone = ++ver;
        len[clone] = len[p] + 1;
        for (register int i = 0; i < 26; ++i) nxt[i][clone] = nxt[i][q];
        link[clone] = link[q];
        while (p && nxt[c][p] == q) {
          nxt[c][p] = clone;
          p = link[p];
        }
        link[q] = link[cur] = clone;
      }
    }
    last = cur;
  }
  void build() {
    for (register int i = 2; i <= ver; ++i) v[link[i]].push_back(i);
  }
  void dfs(int p) {
    for (register int i = 0; i < v[p].size(); ++i) {
      dfs(v[p][i]);
      Q.rt[p] = Q.merge(Q.rt[p], Q.rt[v[p][i]], 1, n);
    }
  }
  void query() {
    int l, r, now = 1, lim;
    l = read();
    r = read();
    scanf("%s", s + 1);
    m = strlen(s + 1);
    for (lim = 1;; ++lim) {
      npos[lim] = -1;
      for (register int i = max(s[lim] - 'a' + 1, 0), p; i < 26; ++i) {
        p = nxt[i][now];
        if (p && Q.query(Q.rt[p], l + lim - 1, r, 1, n)) {
          npos[lim] = i;
          break;
        }
      }
      if (lim == m + 1) break;
      now = nxt[s[lim] - 'a'][now];
      if (!now || !Q.query(Q.rt[now], l + lim - 1, r, 1, n)) break;
    }
    while (lim && npos[lim] == -1) --lim;
    if (lim) {
      for (register int i = 1; i < lim; ++i) putchar(s[i]);
      putchar('a' + npos[lim]);
      putchar('\n');
    } else
      puts("-1");
  }
} T;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  T.reset();
  for (register int i = 1; i <= n; ++i) T.insert(s[i] - 'a');
  T.build();
  T.dfs(1);
  for (register int t = read(); t; --t) T.query();
  return 0;
}