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 std::vector;
const int N(1e5 + 10), M(2e5 + 10), maxn(2e5 + 10);
int n, q;
char s[N], t[M];
namespace Segment_Tree {
struct tree {
  bool exist;
  tree *lson, *rson;
  static tree *null;
  void *operator new(size_t size);
  inline tree() : exist(0) {
    static bool init(0);
    if (!init) init = 1, null = new tree, null->lson = null->rson = null;
    lson = rson = null;
  }
  inline const void pushup() { exist = lson->exist || rson->exist; }
} * tree::null;
char memory_pool[maxn * 40 * sizeof(tree)],
    *tail(memory_pool + sizeof memory_pool);
inline void *tree::operator new(size_t size) { return tail -= size; }
inline const void insert(tree *&p, const int &l, const int &r, const int &pos) {
  if (p == tree::null) p = new tree;
  p->exist = 1;
  if (l == r) return;
  const int mid(l + r >> 1);
  if (pos <= mid)
    insert(p->lson, l, mid, pos);
  else
    insert(p->rson, mid + 1, r, pos);
}
inline const bool query(tree *p, const int &l, const int &r, const int &L,
                        const int &R) {
  if (p == tree::null) return 0;
  if (l > R || r < L) return 0;
  if (l >= L && r <= R) return p->exist;
  const int mid(l + r >> 1);
  if (query(p->lson, l, mid, L, R)) return 1;
  return query(p->rson, mid + 1, r, L, R);
}
inline tree *merge(tree *a, tree *b, const int &l, const int &r) {
  if (a == tree::null && b == tree::null) return tree::null;
  if (a == tree::null) return b;
  if (b == tree::null) return a;
  tree *p(new tree);
  if (l == r) return p->exist = a->exist || b->exist, p;
  const int mid(l + r >> 1);
  p->lson = merge(a->lson, b->lson, l, mid);
  p->rson = merge(a->rson, b->rson, mid + 1, r);
  p->pushup();
  return p;
}
}  // namespace Segment_Tree
using namespace Segment_Tree;
namespace Suffix_Automaton {
struct node {
  int len;
  bool vis;
  tree *root;
  vector<node *> son;
  static node *null;
  node *trans[26], *fa;
  void *operator new(size_t size);
  inline node() : len(0), vis(0) {
    static bool init(0);
    if (!init) {
      init = 1;
      null = new node;
      for (int i(0); i < 26; i++) null->trans[i] = null;
      null->fa = null;
    }
    root = new tree;
    for (int i(0); i < 26; i++) trans[i] = null;
    fa = null;
  }
  inline const void travel() {
    vis = 1;
    if (fa != null) fa->son.push_back(this);
    for (int i(0); i < 26; i++)
      if (trans[i] != null && !trans[i]->vis) trans[i]->travel();
  }
  inline const void dfs() {
    for (vector<node *>::iterator i(son.begin()); i != son.end(); i++)
      (*i)->dfs(), root = merge(root, (*i)->root, 1, n);
  }
  inline const bool exist(const int &len, const int &l, const int &r) {
    if (this == null) return 0;
    return query(root, 1, n, l + len - 1, r);
  }
} * last, *root, *node::null;
char memory_pool[maxn * sizeof(node)], *tail(memory_pool + sizeof memory_pool);
inline void *node::operator new(size_t size) { return tail -= size; }
inline const void init() { last = root = new node; }
inline const void extend(const char &c, const int &k) {
  node *np(new node), *p(last);
  (last = np)->len = p->len + 1;
  insert(np->root, 1, n, k);
  for (; p != node::null && p->trans[c] == node::null; p = p->fa)
    p->trans[c] = np;
  if (p == node::null) return np->fa = root, void();
  node *q(p->trans[c]);
  if (q->len == p->len + 1) return np->fa = q, void();
  node *nq(new node);
  nq->len = p->len + 1;
  for (int i(0); i < 26; i++) nq->trans[i] = q->trans[i];
  nq->fa = q->fa;
  np->fa = q->fa = nq;
  for (; p->trans[c] == q; p = p->fa) p->trans[c] = nq;
}
inline const void build() {
  init();
  for (int i(1); i <= n; i++) extend(s[i] - 'a', i);
  root->travel();
  root->dfs();
}
inline const void query(const int &l, const int &r) {
  const int m(strlen(t + 1));
  node *p(root);
  char o;
  int pos(0);
  for (int i(1); i <= m + 1; i++) {
    for (int j(i <= m ? t[i] - 'a' + 1 : 0); j < 26; j++)
      if (p->trans[j]->exist(i, l, r)) {
        o = j + 'a';
        pos = i;
        break;
      }
    if (i <= m && p->trans[t[i] - 'a']->exist(i, l, r))
      p = p->trans[t[i] - 'a'];
    else
      break;
  }
  if (!pos) return puts("-1"), void();
  for (int i(1); i < pos; i++) putchar(t[i]);
  putchar(o);
  putchar('\n');
}
}  // namespace Suffix_Automaton
using namespace Suffix_Automaton;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  build();
  scanf("%d", &q);
  for (int l, r; q--;) scanf("%d%d", &l, &r), scanf("%s", t + 1), query(l, r);
  return 0;
}