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>
namespace IO {
template <typename T>
inline void swap(T &x, T &y) {
  T tmp = x;
  x = y, y = tmp;
}
template <typename T>
inline T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
inline T min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
inline T max(T x, T y) {
  return x > y ? x : y;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
}  // namespace IO
using namespace IO;
const int MAXN = 2e5;
int N, Q;
char str[MAXN + 7];
struct Smt {
  struct Node {
    Node *left, *right;
    Node() : left(NULL), right(NULL) {}
  } * root[MAXN * 2 + 7];
  void insert(int L, int l, int r, Node *&now) {
    now = new Node();
    if (l == r) return;
    int mid = (l + r) >> 1;
    if (L <= mid)
      insert(L, l, mid, now->left);
    else
      insert(L, mid + 1, r, now->right);
  }
  Node *merge(Node *a, Node *b) {
    if (a == NULL) return b;
    if (b == NULL) return a;
    Node *now = new Node();
    now->left = merge(a->left, b->left);
    now->right = merge(a->right, b->right);
    return now;
  }
  int query(int L, int R, int l, int r, Node *now) {
    if (now == NULL) return 0;
    if (L <= l && r <= R) return 1;
    int mid = (l + r) >> 1;
    if (L <= mid)
      if (query(L, R, l, mid, now->left)) return 1;
    if (mid < R)
      if (query(L, R, mid + 1, r, now->right)) return 1;
    return 0;
  }
} smt;
struct Sam {
  struct Node {
    int fa, len;
    int son[26];
  } node[MAXN * 2 + 7];
  int last = 1, cntNode = 1;
  void extend(int c) {
    int p = last, np = last = ++cntNode;
    node[np].len = node[p].len + 1;
    smt.insert(node[np].len, 1, N, smt.root[np]);
    for (; p && !node[p].son[c]; p = node[p].fa) node[p].son[c] = np;
    if (!p)
      node[np].fa = 1;
    else {
      int q = node[p].son[c];
      if (node[q].len == node[p].len + 1)
        node[np].fa = q;
      else {
        int nq = ++cntNode;
        node[nq] = node[q];
        node[nq].len = node[p].len + 1;
        for (; p && node[p].son[c] == q; p = node[p].fa) node[p].son[c] = nq;
        node[np].fa = node[q].fa = nq;
      }
    }
  }
  int cntLen[MAXN * 2 + 7], idx[MAXN * 2 + 7];
  void prepare() {
    for (int i = 1; i <= cntNode; ++i) ++cntLen[node[i].len];
    for (int i = 1; i <= cntNode; ++i) cntLen[i] += cntLen[i - 1];
    for (int i = 1; i <= cntNode; ++i) idx[cntLen[node[i].len]--] = i;
    for (int i = cntNode; i; --i)
      smt.root[node[idx[i]].fa] =
          smt.merge(smt.root[node[idx[i]].fa], smt.root[idx[i]]);
  }
  void query(int l, int r, char *str) {
    std::vector<int> vec;
    for (int i = 0, u = 1;; ++i) {
      int c = str[i] - 'a';
      int nex = -1;
      for (int j = max(c + 1, 0); j < 26; ++j)
        if (node[u].son[j] &&
            smt.query(l + i, r, 1, N, smt.root[node[u].son[j]])) {
          nex = j;
          break;
        }
      vec.push_back(nex);
      if (c < 0 || !node[u].son[c] ||
          !smt.query(l + i, r, 1, N, smt.root[node[u].son[c]]))
        break;
      u = node[u].son[c];
    }
    while (!vec.empty() && !~vec.back()) vec.pop_back();
    if (vec.empty())
      puts("-1");
    else {
      for (int i = 0, endi = vec.size() - 1; i < endi; ++i) std::cout << str[i];
      std::cout << char(vec.back() + 'a');
      puts("");
    }
  }
} sam;
void input() {
  scanf("%s", str);
  N = strlen(str);
  for (int i = 0; i < N; ++i) sam.extend(str[i] - 'a');
  sam.prepare();
}
void solve() {
  scanf("%d", &Q);
  while (Q--) {
    int l, r;
    scanf("%d %d %s", &l, &r, str);
    sam.query(l, r, str);
  }
}
void Main() {
  input();
  solve();
}
int main() {
  Main();
  return 0;
}