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 Len = 1e5 + 5;
namespace segt {
const int S = Len << 6;
int lc[S], rc[S];
int total = 0;
void insert(int& x, int p, int l = 1, int r = Len) {
  if (!x) x = ++total;
  if (l == r) return;
  if (p <= ((l + r) >> 1))
    insert(lc[x], p, l, ((l + r) >> 1));
  else
    insert(rc[x], p, ((l + r) >> 1) + 1, r);
}
int merge(int x, int y, int l = 1, int r = Len) {
  if (l == r || !x || !y) return x | y;
  int z = ++total;
  lc[z] = merge(lc[x], lc[y], l, ((l + r) >> 1));
  rc[z] = merge(rc[x], rc[y], ((l + r) >> 1) + 1, r);
  return z;
}
bool find(int u, int v, int x, int l = 1, int r = Len) {
  if (!x) return false;
  if (u <= l && r <= v) return true;
  if (u <= ((l + r) >> 1) && find(u, v, lc[x], l, ((l + r) >> 1))) return true;
  if (v > ((l + r) >> 1) && find(u, v, rc[x], ((l + r) >> 1) + 1, r))
    return true;
  return false;
}
};  // namespace segt
namespace SAM {
const int T = Len << 1;
struct Node {
  map<char, int> ch;
  int link, len, eprt;
} t[T];
int total;
int last;
void extend_char(char c) {
  int p = last, np = last = ++total;
  t[np].len = t[p].len + 1;
  for (; p && !t[p].ch[c]; p = t[p].link) t[p].ch[c] = np;
  if (!p) {
    t[np].link = 1;
  } else {
    int q = t[p].ch[c];
    if (t[p].len + 1 == t[q].len) {
      t[np].link = q;
    } else {
      int nq = ++total;
      t[nq] = t[q], t[nq].len = t[p].len + 1;
      t[np].link = t[q].link = nq;
      for (; p && t[p].ch[c] == q; p = t[p].link) t[p].ch[c] = nq;
    }
  }
  segt::insert(t[np].eprt, t[np].len);
}
int b[T], c[T];
void topo_sort() {
  for (register int i = 1; i <= total; i++) ++c[t[i].len];
  for (register int i = 1; i <= total; i++) c[i] += c[i - 1];
  for (register int i = 1; i <= total; i++) b[c[t[i].len]--] = i;
}
void init_end_pos() {
  for (register int i = total; i; i--) {
    int x = b[i], f = t[x].link;
    if (f) t[f].eprt = segt::merge(t[x].eprt, t[f].eprt);
  }
}
void init_data(string& s) {
  total = last = 1;
  for (string::iterator it = s.begin(); it != s.end(); it++) extend_char(*it);
  topo_sort();
  init_end_pos();
}
int dir[Len];
string query(int l, int r, string str);
};  // namespace SAM
string SAM::query(int l, int r, string str) {
  int x = 1, y, i;
  for (i = 1;; i++) {
    dir[i] = -1;
    char c = (i > str.size()) ? 'a' : str[i - 1] + 1;
    map<char, int>::iterator it = t[x].ch.lower_bound(c);
    for (; it != t[x].ch.end(); it++) {
      y = it->second;
      if (segt::find(l + i - 1, r, t[y].eprt)) {
        dir[i] = it->first;
        break;
      }
    }
    c = (i > str.size()) ? 0 : str[i - 1];
    y = t[x].ch[c];
    if (!y || i == str.size() + 1 || !segt::find(l + i - 1, r, t[y].eprt))
      break;
    x = y;
  }
  for (; i && dir[i] == -1; i--)
    ;
  if (!i) return "-1";
  string ret;
  for (register int j = 1; j < i; j++) ret += str[j - 1];
  ret += dir[i];
  return ret;
}
signed main() {
  ios::sync_with_stdio(false);
  string str;
  cin >> str;
  SAM::init_data(str);
  int q;
  cin >> q;
  while (q--) {
    int L, R;
    cin >> L >> R >> str;
    cout << SAM::query(L, R, str) << '\n';
  }
  return 0;
}