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". 
#include <bits/stdc++.h>
using namespace std;
namespace whatever {
int readu() {
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  int value = ch - '0';
  ch = getchar();
  while (isdigit(ch)) {
    value = value * 10 + ch - '0';
    ch = getchar();
  }
  return value;
}
void init_suffix(char *str, int n, int *suffix, int *rank, int *lcp) {
  ++n;
  for (int i = 0; i < n; ++i) rank[i] = int(str[i]);
  for (int s = 1; s < n; s *= 2) {
    int size = max(128, n);
    static int cnt[100000 + 1];
    static int temp[100000 + 1];
    memset(cnt, 0, sizeof(int) * size);
    for (int i = 0; i < n; ++i) ++cnt[rank[s + i]];
    for (int i = 1; i < size; ++i) cnt[i] += cnt[i - 1];
    for (int i = 0; i < n; ++i) temp[--cnt[rank[s + i]]] = i;
    memset(cnt, 0, sizeof(int) * size);
    for (int i = 0; i < n; ++i) ++cnt[rank[i]];
    for (int i = 1; i < size; ++i) cnt[i] += cnt[i - 1];
    for (int i = n - 1; i != -1; --i) suffix[--cnt[rank[temp[i]]]] = temp[i];
    assert(suffix[0] == n - 1);
    temp[n - 1] = 0;
    for (int i = 1; i < n; ++i)
      temp[suffix[i]] = temp[suffix[i - 1]] +
                        int(rank[suffix[i]] != rank[suffix[i - 1]] ||
                            rank[suffix[i] + s] != rank[suffix[i - 1] + s]);
    memcpy(rank, temp, sizeof(int) * n);
  }
  int cur = 0;
  for (int i = 0; str[i] != '\0'; ++i) {
    if (cur != 0) --cur;
    int prev = suffix[rank[i] - 1];
    while (str[prev + cur] == str[i + cur]) ++cur;
    lcp[rank[i] - 1] = cur;
  }
}
uint8_t log_table[100000 + 1];
int st[17][100000];
void init_st(int *lcp, int n) {
  log_table[1] = 0;
  for (int i = 2; i <= n; ++i)
    log_table[i] = log_table[i - 1] + int((i & (i - 1)) == 0);
  memcpy(st[0], lcp, sizeof(int) * n);
  for (int l = 1; l < 17; ++l)
    for (int i = (1 << l); i <= n; ++i)
      st[l][i - (1 << l)] =
          min(st[l - 1][i - (1 << l)], st[l - 1][i - (1 << (l - 1))]);
}
int query(int a, int b) {
  assert(a != b);
  if (a > b) swap(a, b);
  int l = log_table[b - a];
  return min(st[l][a], st[l][b - (1 << l)]);
}
struct node_type {
  node_type *left;
  node_type *right;
  int min;
};
const int s = (1 << 17);
node_type node[18 * (100000 + 1) + 1];
int node_cnt;
node_type *allocate() { return &node[node_cnt++]; }
node_type *nil = allocate();
node_type *insert(node_type *prev, int index, int value) {
  node_type *root = allocate();
  node_type *cur = root;
  for (int bit = (s >> 1); bit != 0; bit >>= 1) {
    assert(value < prev->min);
    cur->min = value;
    if (index & bit) {
      cur->left = prev->left;
      cur = cur->right = allocate();
      prev = prev->right;
    } else {
      cur->right = prev->right;
      cur = cur->left = allocate();
      prev = prev->left;
    }
  }
  assert(value < prev->min);
  cur->min = value;
  return root;
}
int suffix_query(node_type *cur, int index, int bit) {
  int result = INT_MAX;
  for (; bit != 0; bit >>= 1)
    if (index & bit)
      cur = cur->right;
    else {
      result = min(result, cur->right->min);
      cur = cur->left;
    }
  result = min(result, cur->min);
  return result;
}
int prefix_query(node_type *cur, int index, int bit) {
  int result = INT_MAX;
  for (; bit != 0; bit >>= 1)
    if (index & bit) {
      result = min(result, cur->left->min);
      cur = cur->right;
    } else
      cur = cur->left;
  result = min(result, cur->min);
  return result;
}
int range_query(node_type *cur, int first, int last) {
  assert(first <= last);
  for (int bit = (s >> 1); bit != 0; bit >>= 1)
    if (first & bit)
      cur = cur->right;
    else if (!(last & bit))
      cur = cur->left;
    else
      return min(suffix_query(cur->left, first, (bit >> 1)),
                 prefix_query(cur->right, last, (bit >> 1)));
  return cur->min;
}
void run() {
  nil->left = nil->right = nil;
  nil->min = INT_MAX;
  static char s[100000 + 1];
  gets(s);
  int n = int(strlen(s));
  static int suffix[100000 + 1];
  static int rank[100000 + 1 + (1 << 16)];
  static int lcp[100000];
  init_suffix(s, n, suffix, rank, lcp);
  init_st(lcp, n);
  node_type *cur = nil;
  static node_type *root[100001];
  for (int i = n; i != -1; --i) root[i] = cur = insert(cur, suffix[i], i);
  int q = readu();
  while (--q != -1) {
    int l = readu() - 1;
    int r = readu() - 1;
    static char x[200000 + 1];
    gets(x);
    int m = int(strlen(x));
    x[m] = char(1);
    int left = 0;
    int right = n + 1;
    int prev = 0;
    int length = 0;
    while (left + 1 != right) {
      int mid = (left + right) / 2;
      if (query(prev, mid) < length) {
        if (prev < mid)
          right = mid;
        else
          left = mid;
      } else {
        prev = mid;
        while (s[suffix[mid] + length] == x[length]) ++length;
        if (s[suffix[mid] + length] < x[length])
          left = mid;
        else
          right = mid;
      }
    }
    int result = n + 1;
    if (right != n + 1) {
      if (prev == left) {
        length = min(length, lcp[left]);
        while (s[suffix[right] + length] == x[length]) ++length;
        assert(s[suffix[right] + length] > x[length]);
      }
      if (l <= r - m) result = min(result, range_query(root[right], l, r - m));
      for (int i = max(l, r - m + 1); i <= r; ++i)
        if (rank[i] >= right &&
            min((rank[i] == right ? INT_MAX : query(right, rank[i])), length) <
                r - i + 1)
          result = min(result, rank[i]);
    }
    if (result != n + 1) {
      length =
          min((result == right ? INT_MAX : query(right, result)), length) + 1;
      for (int i = 0; i < length; ++i) putchar(s[suffix[result] + i]);
      putchar('\n');
    } else
      puts("-1");
  }
}
}  // namespace whatever
int main() { whatever::run(); }
