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 N = 1e6 + 10;
const int mod = 1e9 + 7;
const int SN = 2e5 + 100;
struct seg {
  int l, r, sum;
} tree[SN * 20];
int scnt;
void pushup(int pos) {
  tree[pos].sum = tree[tree[pos].l].sum + tree[tree[pos].r].sum;
}
void modify(int &pos, int l, int r, int w) {
  if (!pos) pos = ++scnt;
  if (l == r) {
    tree[pos].sum++;
    return;
  }
  int mid = (l + r) >> 1;
  if (w <= mid)
    modify(tree[pos].l, l, mid, w);
  else
    modify(tree[pos].r, mid + 1, r, w);
  pushup(pos);
}
int query(int pos, int ql, int qr, int l, int r) {
  if (ql <= l && r <= qr) return tree[pos].sum;
  int mid = (l + r) >> 1;
  int res = 0;
  if (ql <= mid) res += query(tree[pos].l, ql, qr, l, mid);
  if (qr > mid) res += query(tree[pos].r, ql, qr, mid + 1, r);
  return res;
}
int merge(int u, int v, int l, int r) {
  if (!u || !v) return u + v;
  int pos = ++scnt;
  if (l == r) {
    tree[pos].sum = tree[u].sum + tree[v].sum;
    return pos;
  }
  int mid = (l + r) >> 1;
  tree[pos].l = merge(tree[u].l, tree[v].l, l, mid);
  tree[pos].r = merge(tree[u].r, tree[v].r, mid + 1, r);
  pushup(pos);
  return pos;
}
int rt[SN], n;
struct SAM {
  int trans[SN][26];
  int mxl[SN], link[SN], pre, scnt;
  SAM() { pre = scnt = 1; };
  void init() {
    for (int j = 1; j <= scnt; j++) {
      link[j] = 0;
      mxl[j] = 0;
      memset(trans[j], 0, sizeof(trans[j]));
    }
    scnt = pre = 1;
  };
  void insert(int id) {
    int cur = ++scnt;
    mxl[cur] = mxl[pre] + 1;
    int u;
    modify(rt[cur], 1, n, mxl[cur]);
    for (u = pre; u && !trans[u][id]; u = link[u]) trans[u][id] = cur;
    pre = cur;
    if (!u)
      link[cur] = 1;
    else {
      int x = trans[u][id];
      if (mxl[x] == mxl[u] + 1)
        link[cur] = x;
      else {
        int nc = ++scnt;
        link[nc] = link[x];
        mxl[nc] = mxl[u] + 1;
        memcpy(trans[nc], trans[x], sizeof(trans[x]));
        link[cur] = link[x] = nc;
        for (; u && trans[u][id] == x; u = link[u]) trans[u][id] = nc;
      }
    }
  }
} sam;
struct edge {
  int to, nxt;
} e[SN];
int ecnt, head[SN];
void addadge(int u, int v) {
  e[++ecnt].to = v;
  e[ecnt].nxt = head[u];
  head[u] = ecnt;
}
void dfs(int x) {
  for (int i = head[x]; i; i = e[i].nxt) {
    int to = e[i].to;
    dfs(to);
    rt[x] = merge(rt[x], rt[to], 1, n);
  }
}
void solve(int l, int r, char *t) {
  int u = 1;
  int len = strlen(t + 1);
  t[len + 1] = 'a' - 1;
  int ansi = -1, ansj = -1;
  for (int i = 1; i <= len + 1; i++) {
    for (int j = t[i] - 'a' + 1; j < 26; j++) {
      int v = sam.trans[u][j];
      if (v && query(rt[v], l + i - 1, r, 1, n)) {
        ansi = i;
        ansj = j;
        break;
      }
    }
    if (i == len + 1) break;
    u = sam.trans[u][t[i] - 'a'];
    if (!u || !query(rt[u], l + i - 1, r, 1, n)) break;
  }
  if (ansi == -1)
    printf("-1\n");
  else {
    for (int i = 1; i <= ansi - 1; i++) printf("%c", t[i]);
    printf("%c", ansj + 'a');
    printf("\n");
  }
}
char s[N], t[N];
int q;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) sam.insert(s[i] - 'a');
  for (int i = 2; i <= sam.scnt; i++) addadge(sam.link[i], i);
  dfs(1);
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d%d%s", &l, &r, t + 1);
    solve(l, r, t);
  }
}