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;
char s[200010];
int len;
struct State {
  int fa, len;
  int ch[30];
} pos[200010 << 1];
int SUM;
int tot = 1, las = 1;
struct seg_tree {
  int cnt;
  int rt[200010 << 1];
  int lson[200010 * 40], rson[200010 * 40];
  int you[200010 * 40];
  int merge(int now, int pre, int l, int r) {
    if (!now || !pre) return now | pre;
    int x = ++cnt;
    you[x] = you[now] | you[pre];
    if (l == r) return x;
    int mid = l + r >> 1;
    lson[x] = merge(lson[now], lson[pre], l, mid);
    rson[x] = merge(rson[now], rson[pre], mid + 1, r);
    return x;
  }
  void insert(int &now, int l, int r, int t, int q) {
    if (!now) now = ++cnt;
    if (q >= 0) you[now] |= 1 << q;
    if (l == r) return;
    int mid = l + r >> 1;
    if (t <= mid)
      insert(lson[now], l, mid, t, q);
    else
      insert(rson[now], mid + 1, r, t, q);
  }
  bool query1(int now, int l, int r, int ll, int rr) {
    if (!now || ll > rr) return 0;
    if (ll <= l && r <= rr) return 1;
    bool A = 0;
    int mid = l + r >> 1;
    if (ll <= mid) A |= query1(lson[now], l, mid, ll, rr);
    if (rr >= mid + 1) A |= query1(rson[now], mid + 1, r, ll, rr);
    return A;
  }
  bool query(int now, int l, int r, int ll, int rr, int q) {
    if (!now || ll > rr) return 0;
    if (ll <= l && r <= rr) return you[now] & (1 << q);
    int mid = l + r >> 1;
    bool A = 0;
    if (ll <= mid) A |= query(lson[now], l, mid, ll, rr, q);
    if (rr >= mid + 1) A |= query(rson[now], mid + 1, r, ll, rr, q);
    return A;
  }
} S;
void insert(int t, int id) {
  int p = las, np = las = ++tot;
  pos[np].len = pos[p].len + 1;
  for (; p && !pos[p].ch[t]; p = pos[p].fa) pos[p].ch[t] = np;
  if (!p)
    pos[np].fa = 1;
  else {
    int q = pos[p].ch[t];
    if (pos[q].len == pos[p].len + 1)
      pos[np].fa = q;
    else {
      int nq = ++tot;
      pos[nq] = pos[q];
      pos[nq].len = pos[p].len + 1;
      pos[np].fa = pos[q].fa = nq;
      for (; p && pos[p].ch[t] == q; p = pos[p].fa) pos[p].ch[t] = nq;
    }
  }
  S.insert(S.rt[np], 0, len, id,
           (s[id + 1] >= 'a' && s[id + 1] <= 'z') ? s[id + 1] - 'a' : -1);
}
int head[200010 << 1], last[200010 << 1], v[200010 << 1], p;
void add(int a, int b) {
  v[++p] = b;
  last[p] = head[a];
  head[a] = p;
}
inline int read() {
  int sum = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch <= '9' && ch >= '0') sum = sum * 10 + ch - '0', ch = getchar();
  return sum;
}
void dfs(int a) {
  for (int i = head[a]; i; i = last[i]) {
    dfs(v[i]);
    S.rt[a] = S.merge(S.rt[a], S.rt[v[i]], 0, len);
  }
}
char t[200010 << 1];
pair<int, int> ans;
char Ad;
int main() {
  scanf("%s", &s[1]);
  len = strlen(&s[1]);
  for (int i = 1; i <= len; i++) insert(s[i] - 'a', i);
  for (int i = 2; i <= tot; i++) add(pos[i].fa, i);
  S.insert(S.rt[1], 0, len, 0, s[1] - 'a');
  dfs(1);
  int q = read();
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    scanf("%s", &t[1]);
    int len_t = strlen(&t[1]);
    ans = make_pair(-1, -1);
    int now = 1;
    int Pr = 1;
    while (Pr <= len_t) {
      for (int i = t[Pr] - 'a' + 1; i < 26; i++)
        if (S.query(S.rt[now], 0, len, l + Pr - 2, r - 1, i)) {
          ans = make_pair(1, Pr - 1);
          Ad = char((int)'a' + i);
          break;
        }
      if (pos[now].ch[t[Pr] - 'a'] &&
          (S.query1(S.rt[pos[now].ch[t[Pr] - 'a']], 0, len, l + Pr - 1, r))) {
        now = pos[now].ch[t[Pr] - 'a'];
        ++Pr;
      } else
        break;
    }
    if (Pr == len_t + 1) {
      for (int i = 0; i < 26; i++)
        if (S.query(S.rt[now], 0, len, l + Pr - 2, r - 1, i)) {
          ans = make_pair(1, Pr - 1);
          Ad = char((int)'a' + i);
          break;
        }
    }
    if (ans.first == -1)
      cout << -1 << '\n';
    else {
      for (int j = ans.first; j <= ans.second; j++) cout << t[j];
      cout << Ad << '\n';
    }
  }
  return 0;
}