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;
template <typename T>
inline void read(T &a) {
  T w = 1;
  a = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) a = (a * 10) + (ch - '0');
  a *= w;
}
template <typename T>
inline void ckmax(T &a, T b) {
  a = a > b ? a : b;
}
template <typename T>
inline void ckmin(T &a, T b) {
  a = a < b ? a : b;
}
const int MAX = 1e6 + 10;
const int MAXN = 2e5 + 10;
char t[MAX], *all = t;
struct state {
  int link, nex[26], len;
} st[MAX];
int last, siz;
int Id[MAX];
inline void init() {
  st[0].link = -1;
  st[0].len = 0;
}
inline void insert(int c, int o) {
  int cur = ++siz, p = last;
  last = cur;
  Id[o] = cur;
  while (p != -1 && !st[p].nex[c]) {
    st[p].nex[c] = cur;
    p = st[p].link;
  }
  if (p == -1)
    st[cur].link = 0;
  else {
    int q = st[p].nex[c];
    if (st[p].len + 1 == st[q].len)
      st[cur].link = q;
    else {
      int clone = ++siz;
      st[clone].len = st[p].len + 1;
      st[clone].link = st[q].link;
      for (int i = 0; i < 26; ++i) st[clone].nex[i] = st[q].nex[i];
      st[q].link = st[cur].link = clone;
      while (p != -1 && st[p].nex[c] == q) {
        st[p].nex[c] = clone;
        p = st[p].link;
      }
    }
  }
}
struct edge {
  int to, nex;
} e[MAX];
int head[MAX], cnt;
inline void add(int u, int v) {
  e[++cnt].to = v;
  e[cnt].nex = head[u];
  head[u] = cnt;
}
int dfn[MAX], low[MAX], tot;
void dfs(int u) {
  dfn[u] = ++tot;
  for (int i = head[u]; i; i = e[i].nex) {
    dfs(e[i].to);
  }
  low[u] = tot;
}
struct question {
  int l, r, id, len;
  char *t;
  bool operator<(const question &x) const { return r < x.r; }
} que[MAX];
struct seg {
  int mx;
} tr[MAX << 1];
inline void pushup(int now) {
  tr[now].mx = max(tr[now << 1].mx, tr[now << 1 | 1].mx);
}
void Update(int now, int l, int r, int pos, int v) {
  if (l == r) {
    tr[now].mx = max(tr[now].mx, v);
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    Update(now << 1, l, mid, pos, v);
  else
    Update(now << 1 | 1, mid + 1, r, pos, v);
  pushup(now);
}
int query(int now, int l, int r, int ll, int rr) {
  if (ll <= l && r <= rr) return tr[now].mx;
  int mid = (l + r) >> 1, ans = 0;
  if (ll <= mid) ckmax(ans, query(now << 1, l, mid, ll, rr));
  if (rr > mid) ckmax(ans, query(now << 1 | 1, mid + 1, r, ll, rr));
  return ans;
}
bool check(int l, int o, int len) {
  int Max_Endpos = query(1, 1, tot, dfn[o], low[o]);
  if (Max_Endpos - len + 1 >= l) return 1;
  return 0;
}
bool tag[MAX];
string Ans[MAXN];
bool get(int now, int id, int Len, int idd) {
  if (que[id].len < Len) {
    for (int i = 0; i < 26; ++i) {
      if (st[now].nex[i] && check(que[id].l, st[now].nex[i], Len)) {
        tag[idd] = 1;
        Ans[idd] += 'a' + i;
        return 1;
      }
    }
    return 0;
  }
  int c = que[id].t[Len] - 'a';
  int Next = st[now].nex[c];
  if (Next && check(que[id].l, Next, Len) && get(Next, id, Len + 1, idd)) {
    Ans[idd] += 'a' + c;
    return 1;
  } else {
    for (int i = c + 1; i < 26; ++i) {
      if (st[now].nex[i] && check(que[id].l, st[now].nex[i], Len)) {
        tag[idd] = 1;
        Ans[idd] += i + 'a';
        return 1;
      }
    }
    return 0;
  }
}
int main() {
  string czj;
  cin >> czj;
  init();
  for (int i = 0; i < czj.size(); ++i) insert(czj[i] - 'a', i + 1);
  for (int i = 1; i <= siz; ++i) add(st[i].link, i);
  dfs(0);
  int q;
  read(q);
  for (int i = 1; i <= q; ++i) {
    scanf("%d %d %s", &que[i].l, &que[i].r, all + 1);
    que[i].t = all;
    que[i].id = i;
    que[i].len = strlen(que[i].t + 1);
    all += que[i].len + 1;
  }
  sort(que + 1, que + q + 1);
  int r = 0;
  for (int i = 1; i <= q; ++i) {
    for (; r <= que[i].r; ++r) Update(1, 1, tot, dfn[Id[r]], r);
    get(0, i, 1, que[i].id);
  }
  for (int i = 1; i <= q; ++i) {
    if (!tag[i])
      puts("-1");
    else {
      int Size = Ans[i].size() - 1;
      for (int j = Size; j >= 0; --j) {
        cout << Ans[i][j];
      }
      puts("");
    }
  }
}