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;
int n, q, l, r;
char s[210000];
struct SAM {
  int last, tot, id, l[30 * 210000], r[30 * 210000], s[30 * 210000], v[210000],
      root[210000], son[210000][26], len[210000], link[210000];
  vector<int> g[210000];
  void init() {
    memset(son[1], 0, sizeof(son[1]));
    last = tot = 1;
  }
  void insert(int c) {
    int cur = ++tot, p;
    v[cur] = 1;
    len[cur] = len[last] + 1;
    memset(son[cur], 0, sizeof(son[cur]));
    p = last;
    while (p && !son[p][c]) son[p][c] = cur, p = link[p];
    if (!p)
      link[cur] = 1;
    else {
      int q = son[p][c];
      if (len[p] + 1 == len[q])
        link[cur] = q;
      else {
        ++tot;
        for (int i = 0; i < 26; i++) son[tot][i] = son[q][i];
        link[tot] = link[q];
        len[tot] = len[p] + 1;
        while (p && son[p][c] == q) son[p][c] = tot, p = link[p];
        link[q] = link[cur] = tot;
      }
    }
    last = cur;
  }
  int merge(int x, int y) {
    if (!x || !y) return x + y;
    int t = ++id;
    s[t] = s[x] + s[y];
    l[t] = merge(l[x], l[y]);
    r[t] = merge(r[x], r[y]);
    return t;
  }
  void add(int &x, int ls, int rs, int k) {
    if (ls > k || rs < k) return;
    if (!x) x = ++id;
    if (ls == rs) {
      s[x]++;
      return;
    }
    int mid = (ls + rs) / 2;
    add(l[x], ls, mid, k);
    add(r[x], mid + 1, rs, k);
    s[x] = s[l[x]] + s[r[x]];
  }
  void dfs(int x) {
    for (auto t : g[x]) {
      dfs(t);
      root[x] = merge(root[x], root[t]);
    }
    if (v[x]) add(root[x], 1, n, len[x]);
  }
  int query(int x, int p, int q, int ls, int rs) {
    if (ls > rs || !x) return 0;
    if (q < ls || p > rs) return 0;
    if (ls <= p && q <= rs) return s[x];
    int mid = (p + q) / 2;
    return query(l[x], p, mid, ls, rs) + query(r[x], mid + 1, q, ls, rs);
  }
  void build() {
    for (int i = 1; i <= tot; i++) g[link[i]].push_back(i);
    dfs(1);
  }
  void solve(char *s, int l, int r) {
    int L = strlen(s + 1), now = 1, pos = 0, ch;
    for (int i = 1; i <= L + 1; i++) {
      int c = (i <= L ? s[i] - 'a' : -1);
      for (int j = c + 1; j < 26; j++)
        if (son[now][j]) {
          int k = son[now][j];
          if (query(root[k], 1, n, l + i - 1, r) > 0) {
            pos = i;
            ch = j;
            break;
          }
        }
      if (i <= L) {
        if (!son[now][c]) break;
        now = son[now][c];
        if (query(root[now], 1, n, l + i - 1, r) == 0) break;
      }
    }
    if (!pos)
      printf("-1\n");
    else {
      for (int i = 1; i < pos; i++) printf("%c", s[i]);
      printf("%c\n", ch + 'a');
    }
  }
} S;
int main() {
  S.init();
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) S.insert(s[i] - 'a');
  S.build();
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d %d %s", &l, &r, s + 1);
    S.solve(s, l, r);
  }
  return 0;
}