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;
inline long long rd() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
const int maxn = 2e5 + 233;
namespace SegmentTree {
const int maxm = maxn * 60;
int lc[maxm], rc[maxm], T[maxm], tot = 0;
inline void insert(int &o, int l, int r, int x, int v) {
  if (!o) o = ++tot, T[o] = 0;
  T[o] |= v;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (x <= mid)
    insert(lc[o], l, mid, x, v);
  else
    insert(rc[o], mid + 1, r, x, v);
}
inline int query(int o, int l, int r, int x, int y) {
  if (!o) return 0;
  if (l == x && r == y) return T[o];
  int mid = (l + r) >> 1;
  if (y <= mid)
    return query(lc[o], l, mid, x, y);
  else if (mid + 1 <= x)
    return query(rc[o], mid + 1, r, x, y);
  else
    return query(lc[o], l, mid, x, mid) | query(rc[o], mid + 1, r, mid + 1, y);
}
inline int merge(int x, int y) {
  if (!x || !y) return x + y;
  int z = ++tot;
  T[z] = T[x] | T[y];
  lc[z] = merge(lc[x], lc[y]);
  rc[z] = merge(rc[x], rc[y]);
  return z;
}
}  // namespace SegmentTree
using SegmentTree::insert;
using SegmentTree::merge;
using SegmentTree::query;
int root[maxn * 2], n;
struct SAM {
  static const int maxm = maxn * 2;
  struct node {
    int link, nxt[26], max;
  } T[maxm];
  int tot, start, last;
  SAM() {
    tot = 0;
    start = last = newnode(0);
  }
  int newnode(int x) {
    ++tot;
    T[tot].link = 0;
    memset(T[tot].nxt, 0, sizeof(T[tot].nxt));
    T[tot].max = x;
    return tot;
  }
  int tpos[maxm], vpos[maxm];
  void extend(char c, int flag) {
    int u = newnode(T[last].max + 1), v = last;
    tpos[v] = flag;
    vpos[v] = c;
    for (; v && T[v].nxt[c] == 0; v = T[v].link) {
      T[v].nxt[c] = u;
    }
    if (!v) {
      T[u].link = start;
    } else if (T[v].max + 1 == T[T[v].nxt[c]].max) {
      T[u].link = T[v].nxt[c];
    } else {
      int n = newnode(T[v].max + 1), o = T[v].nxt[c];
      for (register int i = (0); i < int(26); ++i) T[n].nxt[i] = T[o].nxt[i];
      T[n].link = T[o].link;
      T[o].link = T[u].link = n;
      for (; v && T[v].nxt[c] == o; v = T[v].link) T[v].nxt[c] = n;
    }
    last = u;
  }
  vector<int> edge[maxm];
  void dfs(int u) {
    for (auto v : edge[u]) {
      dfs(v);
      root[u] = merge(root[u], root[v]);
    }
  }
  void init() {
    for (register int i = (1); i <= int(tot); ++i) root[i] = 0;
    for (register int i = (1); i <= int(tot); ++i)
      if (tpos[i]) {
        insert(root[i], 1, n, tpos[i], 1 << vpos[i]);
      }
    for (register int i = (2); i <= int(tot); ++i) {
      edge[T[i].link].push_back(i);
    }
    dfs(1);
  }
} sam;
char S[maxn], T[maxn];
int main() {
  scanf("%s", S + 1);
  n = strlen(S + 1);
  for (register int i = (1); i <= int(n); ++i) sam.extend(S[i] - 'a', i);
  sam.init();
  int Case = rd();
  while (Case--) {
    int l = rd(), r = rd();
    scanf("%s", T + 1);
    T[strlen(T + 1) + 2] = 0;
    T[strlen(T + 1) + 1] = 'a' - 1;
    int p1 = -1, p2 = -1;
    int u = 1;
    for (int i = 1; T[i] && u; i++) {
      int t = query(root[u], 1, n, l + i - 1, r), tmp = T[i] - 'a' + 1;
      for (register int j = (tmp); j < int(26); ++j)
        if (t >> j & 1) {
          p1 = i, p2 = j;
          break;
        }
      if (T[i] >= 'a') u = sam.T[u].nxt[T[i] - 'a'];
    }
    if (p1 == -1) {
      puts("-1");
    } else {
      for (register int i = (1); i < int(p1); ++i) putchar(T[i]);
      putchar('a' + p2);
      puts("");
    }
  }
  return 0;
}