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 inf = (int)1.01e9;
const long long infll = (long long)1.01e18;
const long double eps = 1e-9;
const long double pi = acos((long double)-1);
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
void precalc() {}
const int maxn = (int)2e5 + 5;
int n;
char tmp[maxn];
string s;
int q;
int ql[maxn], qr[maxn];
string qx[maxn];
bool read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = ((int)(s).size());
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%s", &ql[i], &qr[i], tmp);
    ql[i]--;
    qx[i] = tmp;
  }
  return true;
}
const int sigma = 26;
int go[maxn][sigma];
int len[maxn];
int link[maxn];
int vs;
int newNode(int l) {
  for (int i = 0; i < sigma; i++) {
    go[vs][i] = -1;
  }
  len[vs] = l;
  link[vs] = -1;
  return vs++;
}
int addChar(int c, int v) {
  int u = newNode(len[v] + 1);
  while (v != -1 && go[v][c] == -1) {
    go[v][c] = u;
    v = link[v];
  }
  if (v == -1) {
    link[u] = 0;
    return u;
  }
  int w = go[v][c];
  if (len[w] == len[v] + 1) {
    link[u] = w;
    return u;
  }
  int nw = newNode(len[v] + 1);
  memcpy(go[nw], go[w], sizeof(go[w]));
  link[nw] = link[w];
  link[w] = nw;
  link[u] = nw;
  while (v != -1 && go[v][c] == w) {
    go[v][c] = nw;
    v = link[v];
  }
  return u;
}
int ps[maxn];
vector<int> g[maxn];
int tin[maxn], tout[maxn], t;
void dfs(int v) {
  tin[v] = t++;
  for (int i = 0; i < ((int)(g[v]).size()); i++) {
    int u = g[v][i];
    dfs(u);
  }
  tout[v] = t;
}
int st[4 * maxn];
void buildst(int v, int tl, int tr) {
  st[v] = -1;
  if (tl == tr - 1) {
    return;
  }
  int tm = (tl + tr) / 2;
  buildst(2 * v, tl, tm);
  buildst(2 * v + 1, tm, tr);
}
void update(int v, int tl, int tr, int pos, int val) {
  if (tl == tr - 1) {
    st[v] = max(st[v], val);
    return;
  }
  int tm = (tl + tr) / 2;
  if (pos < tm) {
    update(2 * v, tl, tm, pos, val);
  } else {
    update(2 * v + 1, tm, tr, pos, val);
  }
  st[v] = max(st[2 * v], st[2 * v + 1]);
}
int get(int v, int tl, int tr, int l, int r) {
  if (l == tl && r == tr) {
    return st[v];
  }
  int tm = (tl + tr) / 2;
  int res = -1;
  if (l < tm) {
    res = max(res, get(2 * v, tl, tm, l, min(r, tm)));
  }
  if (r > tm) {
    res = max(res, get(2 * v + 1, tm, tr, max(l, tm), r));
  }
  return res;
}
int getPos(int v, int len) { return get(1, 0, vs, tin[v], tout[v]) - len; }
vector<int> qs[maxn];
string qans[maxn];
void solve() {
  {
    vs = 0;
    int curv = newNode(0);
    ps[0] = curv;
    for (int i = 0; i < n; i++) {
      curv = addChar(s[i] - 'a', curv);
      ps[i + 1] = curv;
    }
  }
  for (int i = 0; i < vs; i++) {
    g[i].clear();
  }
  for (int i = 1; i < vs; i++) {
    g[link[i]].push_back(i);
  }
  t = 0;
  dfs(0);
  buildst(1, 0, vs);
  for (int i = 0; i <= n; i++) {
    qs[i].clear();
  }
  for (int i = 0; i < q; i++) {
    qs[qr[i]].push_back(i);
  }
  for (int r = 0; r <= n; r++) {
    {
      int v = ps[r];
      update(1, 0, vs, tin[v], r);
    }
    for (int it = 0; it < ((int)(qs[r]).size()); it++) {
      int id = qs[r][it];
      int v = 0;
      const auto &x = qx[id];
      int anslen = -1;
      char ansc = 'a';
      for (int i = 0; i <= ((int)(x).size()); i++) {
        int c = (i < ((int)(x).size()) ? x[i] - 'a' : -1);
        for (int cc = c + 1; cc < sigma; cc++) {
          if (go[v][cc] == -1) {
            continue;
          }
          int u = go[v][cc];
          if (getPos(u, i + 1) < ql[id]) {
            continue;
          }
          anslen = i;
          ansc = (char)('a' + cc);
          break;
        }
        if (i >= ((int)(x).size())) {
          break;
        }
        if (go[v][c] == -1) {
          break;
        }
        int u = go[v][c];
        if (getPos(u, i + 1) < ql[id]) {
          break;
        }
        v = u;
      }
      if (anslen == -1) {
        qans[id] = "-1";
      } else {
        qans[id] = x.substr(0, anslen) + ansc;
      }
    }
  }
  for (int i = 0; i < q; i++) {
    printf("%s\n", qans[i].c_str());
  }
}
int main() {
  precalc();
  while (read()) {
    solve();
  }
  return 0;
}