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>
void read(T& x) {
  x = 0;
  char ch = getchar();
  long long f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
const int N = 100010;
struct seg_tree {
  int cnt;
  struct node {
    int lc, rc;
    int sum;
  };
  node tr[50 * N];
  int create(int id = 0) {
    tr[id] = {0, 0, 0};
    return cnt = id;
  }
  void init() { create(0); }
  void push_up(int cur) {
    int lc = tr[cur].lc, rc = tr[cur].rc;
    tr[cur].sum = tr[lc].sum + tr[rc].sum;
  }
  void update(int& cur, int l, int r, int x, int k) {
    int mid;
    if (cur == 0) cur = create(cnt + 1);
    if (l == r) {
      tr[cur].sum += k;
      return;
    }
    mid = l + r >> 1;
    if (x <= mid)
      update(tr[cur].lc, l, mid, x, k);
    else
      update(tr[cur].rc, mid + 1, r, x, k);
    push_up(cur);
  }
  int merge(int ca, int cb, int l, int r) {
    int cur, mid;
    if (ca == 0) return cb;
    if (cb == 0) return ca;
    cur = create(cnt + 1);
    if (l == r) {
      tr[cur].sum = tr[ca].sum + tr[cb].sum;
      return ca;
    }
    mid = l + r >> 1;
    tr[cur].lc = merge(tr[ca].lc, tr[cb].lc, l, mid);
    tr[cur].rc = merge(tr[ca].rc, tr[cb].rc, mid + 1, r);
    push_up(cur);
    return cur;
  }
  int query(int cur, int l, int r, int x, int y) {
    int mid;
    int retl, retr;
    if (x == l && y == r) return tr[cur].sum;
    mid = l + r >> 1;
    retl = retr = 0;
    if (x <= mid) retl = query(tr[cur].lc, l, mid, x, min(mid, y));
    if (mid < y) retr = query(tr[cur].rc, mid + 1, r, max(mid + 1, x), y);
    return retl + retr;
  }
} tree;
struct SuffixAutomaton {
  static const int M = 200010;
  int sz, lst;
  int ch[M][26];
  int len[M], link[M];
  int fstPos[M];
  int rt[M];
  void init() {
    create(0);
    lst = 0;
  }
  int create(int id = 0) {
    memset(ch[id], 0, sizeof(ch[0]));
    len[id] = link[id] = fstPos[id] = rt[id] = 0;
    return sz = id;
  }
  void extend(const char* s) {
    for (int i = 0; s[i]; ++i) {
      int c = s[i] - 'a';
      int cur = create(sz + 1);
      len[cur] = len[lst] + 1;
      int p = lst;
      while (ch[p][c] == 0) {
        ch[p][c] = cur;
        p = link[p];
      }
      if (ch[p][c] != cur) {
        int q = ch[p][c];
        if (len[p] + 1 == len[q]) {
          link[cur] = q;
        } else {
          int clone = create(sz + 1);
          memcpy(ch[clone], ch[q], sizeof(ch[q]));
          link[clone] = link[q];
          len[clone] = len[p] + 1;
          fstPos[clone] = fstPos[p];
          while (ch[p][c] == q) {
            ch[p][c] = clone;
            p = link[p];
          }
          link[q] = link[cur] = clone;
        }
      }
      lst = cur;
      fstPos[cur] = i + 1;
      tree.update(rt[cur], 1, 100000, fstPos[cur], 1);
    }
  }
  void build() {
    vector<int> nodes;
    for (int i = 1; i <= sz; ++i) nodes.push_back(i);
    sort(nodes.begin(), nodes.end(),
         [&](int a, int b) { return len[a] > len[b]; });
    for (auto u : nodes) {
      int v = link[u];
      rt[v] = tree.merge(rt[v], rt[u], 1, 100000);
    }
  }
  void run(const char* s, int l, int r) {
    int x = 0, n = 0, m = 0;
    int tmp[M];
    char ans[M];
    tmp[n++] = x;
    ans[m++] = s[0];
    for (int i = 0; s[i]; ++i) {
      int c = s[i] - 'a';
      if (ch[x][c] == 0) break;
      x = ch[x][c];
      tmp[n++] = x;
      ans[m++] = (s[i + 1] ? s[i + 1] : 'a' - 1);
    }
    bool ok = false;
    while (n) {
      if (l + m - 1 > r) {
        --n;
        --m;
        continue;
      }
      for (int i = ans[m - 1] - 'a' + 1; i < 26; ++i) {
        int v = ch[tmp[n - 1]][i];
        if (v == 0) continue;
        if (tree.query(rt[v], 1, 100000, l + m - 1, r)) {
          tmp[n++] = v;
          ans[m - 1] = i + 'a';
          ans[m] = '\0';
          ok = true;
          break;
        }
      }
      if (ok) break;
      --n;
      --m;
    }
    if (ok) {
      printf("%s\n", ans);
    } else {
      printf("-1\n");
    }
  }
} SAM;
char s[100010];
int main() {
  int n;
  int x, y;
  scanf("%s", s);
  SAM.extend(s);
  SAM.build();
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &x, &y);
    scanf("%s", s);
    SAM.run(s, x, y);
  }
  return 0;
}