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". 
#include <bits/stdc++.h>
using namespace std;
const int MAXL = 200111;
char enCode(int a) { return (char)('a' + a); }
string input;
int A[MAXL], Al;
int Id[MAXL];
int M;
int L, R;
int Q[MAXL], Ql;
namespace Sam {
struct Node {
  int s[26], f;
  int l;
} T[MAXL << 1];
int Tcnt, Root, Last;
void Insert(int v) {
  int np = ++Tcnt, at = Last;
  Last = np;
  T[np].l = T[at].l + 1;
  for (; at && !T[at].s[v]; at = T[at].f) T[at].s[v] = np;
  if (!at) {
    T[np].f = Root;
    return;
  }
  int q = T[at].s[v];
  if (T[q].l == T[at].l + 1) {
    T[np].f = q;
    return;
  }
  int nq = ++Tcnt;
  T[nq] = T[q];
  T[nq].l = T[at].l + 1;
  T[q].f = nq;
  T[np].f = nq;
  for (; at && T[at].s[v] == q; at = T[at].f) T[at].s[v] = nq;
}
struct Vert {
  int Son, Bro;
  int Dps, Dpr;
} V[MAXL << 1];
void Link(int a, int b) {
  V[b].Bro = V[a].Son;
  V[a].Son = b;
}
int DFN;
void DFS(int at = Root) {
  ++DFN;
  V[at].Dps = DFN;
  for (int to = V[at].Son; to; to = V[to].Bro) {
    DFS(to);
  }
  V[at].Dpr = DFN;
}
}  // namespace Sam
namespace Chair {
struct Node {
  int ls, rs;
  int cnt;
} T[MAXL * 19];
int Tcnt, Root[MAXL << 1], Rc;
void Update(int &at, int p, int l, int r) {
  ++Tcnt;
  T[Tcnt] = T[at];
  at = Tcnt;
  ++T[at].cnt;
  if (l == r) return;
  int m = (l + r) >> 1;
  if (p > m)
    Update(T[at].rs, p, m + 1, r);
  else
    Update(T[at].ls, p, l, m);
}
int Query(int at, int ql, int qr, int l, int r) {
  if (l >= ql && r <= qr) return T[at].cnt;
  int m = (l + r) >> 1, ret = 0;
  if (ql <= m) ret += Query(T[at].ls, ql, qr, l, m);
  if (qr > m) ret += Query(T[at].rs, ql, qr, m + 1, r);
  return ret;
}
struct Data {
  int dps, pos;
} D[MAXL];
bool cmpdps(Data A, Data B) { return A.dps < B.dps; }
int Dc;
void addD(int a, int b) {
  ++Dc;
  D[Dc].dps = a;
  D[Dc].pos = b;
}
void Calc() {
  sort(D + 1, D + Dc + 1, cmpdps);
  int j = 0;
  for (int i = 1; i <= Dc; ++i) {
    while (j < Rc && j < D[i].dps) {
      ++j;
      Root[j] = Root[j - 1];
    }
    Update(Root[j], D[i].pos, 1, Al);
  }
}
bool Query(int rl, int rr, int pl, int pr) {
  return Query(Root[rr], pl, pr, 1, Al) > Query(Root[rl - 1], pl, pr, 1, Al);
}
int Find(int rl, int rr, int pl, int pr) {
  int pm;
  while (pl < pr) {
    pm = (pl + pr) >> 1;
    if (Query(rl, rr, pl, pm))
      pr = pm;
    else
      pl = pm + 1;
  }
  pm = (pl + pr) >> 1;
  return pm;
}
}  // namespace Chair
int Ansl, Ansr;
bool Ask(int at, int l, int r) {
  int rl = Sam::V[at].Dps, rr = Sam::V[at].Dpr;
  if (Chair::Query(rl, rr, l, r)) {
    Ansr = Chair::Find(rl, rr, l, r);
    Ansl = Ansr - (l - L);
    return true;
  }
  return false;
}
bool Search(int at, int p) {
  using Sam::T;
  if (p <= Ql && T[at].s[Q[p]] && Search(T[at].s[Q[p]], p + 1)) return true;
  if (L + p - 1 > R) return false;
  bool ret = false;
  for (int c = Q[p] + 1; c < 26 && !ret; ++c) {
    if (!T[at].s[c]) continue;
    ret |= Ask(T[at].s[c], L + p - 1, R);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> input;
  Al = input.length();
  for (int i = 1; i <= Al; ++i) A[i] = input[i - 1] - 'a';
  {
    using namespace Sam;
    Last = Root = ++Tcnt;
    for (int i = 1; i <= Al; ++i) {
      Id[i] = Tcnt + 1;
      Insert(A[i]);
    }
    for (int i = 1; i <= Tcnt; ++i)
      if (T[i].f) Link(T[i].f, i);
    DFS();
  }
  for (int i = 1; i <= Al; ++i) Chair::addD(Sam::V[Id[i]].Dps, i);
  Chair::Rc = Sam::Tcnt;
  Chair::Calc();
  cin >> M;
  while (M--) {
    cin >> L >> R >> input;
    Ql = input.length();
    for (int i = 1; i <= Ql; ++i) Q[i] = input[i - 1] - 'a';
    Q[Ql + 1] = -1;
    Ansl = Ansr = 0;
    Search(Sam::Root, 1);
    if (Ansl > Ansr || Ansl < 1 || Ansr > Al)
      cout << "-1" << endl;
    else {
      for (int i = Ansl; i <= Ansr; ++i) cout << enCode(A[i]);
      cout << endl;
    }
  }
  return 0;
}
