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 = 2e5 + 10;
int n, q, last, t, tt, ch[N][26], father[N], len[N], c[N], sorted[N], root[N],
    lc[N * 30], rc[N * 30], one[N * 30];
char s[N], s2[N];
int newnode(int from) {
  ++t;
  len[t] = len[from] + 1;
  return t;
}
void extend(int c) {
  int p = last, np = newnode(p);
  for (; p && !ch[p][c]; p = father[p]) {
    ch[p][c] = np;
  }
  if (!p) {
    father[np] = 1;
  } else {
    int q = ch[p][c];
    if (len[p] + 1 == len[q]) {
      father[np] = q;
    } else {
      int nq = newnode(p);
      memcpy(ch[nq], ch[q], sizeof ch[q]);
      father[nq] = father[q];
      father[np] = father[q] = nq;
      for (; p && ch[p][c] == q; p = father[p]) {
        ch[p][c] = nq;
      }
    }
  }
  last = np;
}
void radix_sort() {
  for (int i = 1; i <= t; ++i) {
    ++c[len[i]];
  }
  for (int i = 1; i <= n; ++i) {
    c[i] += c[i - 1];
  }
  for (int i = t; i; --i) {
    sorted[c[len[i]]--] = i;
  }
}
void modify(int l, int r, int& o, int p) {
  if (!o) {
    o = ++tt;
  }
  if (l == r) {
    one[o] = l;
  } else {
    int mid = l + r >> 1;
    if (p <= mid) {
      modify(l, mid, lc[o], p);
    } else {
      modify(mid + 1, r, rc[o], p);
    }
    one[o] = ~one[lc[o]] ? one[lc[o]] : one[rc[o]];
  }
}
int merge(int x, int y) {
  if (!x || !y) {
    return x | y;
  } else {
    int o = ++tt;
    lc[o] = merge(lc[x], lc[y]);
    rc[o] = merge(rc[x], rc[y]);
    one[o] = ~one[lc[o]] ? one[lc[o]] : one[rc[o]];
    return o;
  }
}
int query(int l, int r, int o, int ql, int qr) {
  if (!o) {
    return -1;
  }
  if (ql <= l && r <= qr) {
    return one[o];
  } else {
    int mid = l + r >> 1, result = -1;
    if (ql <= mid) {
      result = query(l, mid, lc[o], ql, qr);
    }
    if (!~result && qr > mid) {
      result = query(mid + 1, r, rc[o], ql, qr);
    }
    return result;
  }
}
void print(int l, int r) {
  for (int i = l; i <= r; ++i) {
    printf("%c", s[i]);
  }
  puts("");
}
int main() {
  len[0] = -1;
  last = newnode(0);
  scanf("%s%d", s, &q);
  n = strlen(s);
  memset(one, -1, sizeof one);
  for (int i = 0; i < n; ++i) {
    extend(s[i] - 'a');
    modify(0, n - 1, root[last], i);
  }
  radix_sort();
  for (int i = t; i > 1; --i) {
    int u = sorted[i];
    root[father[u]] = merge(root[father[u]], root[u]);
  }
  for (int i = 1; i <= q; ++i) {
    int l, r;
    scanf("%d%d%s", &l, &r, s2);
    --l;
    --r;
    int m = strlen(s2);
    pair<int, int> answer(-1, -1);
    for (int j = 0, o = 1; j <= m && l + j <= r; ++j) {
      for (int k = j < m ? s2[j] - 'a' + 1 : 0; k < 26; ++k) {
        int x = ch[o][k];
        if (!x) {
          continue;
        }
        int pos = query(0, n - 1, root[x], l + j, r);
        if (~pos) {
          answer.first = pos - j;
          answer.second = pos;
          break;
        }
      }
      o = ch[o][s2[j] - 'a'];
      if (!o) {
        break;
      }
    }
    if (~answer.first) {
      print(answer.first, answer.second);
    } else {
      puts("-1");
    }
  }
  return 0;
}