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 std::make_pair;
template <typename T>
inline T read() {
  T x = 0;
  char ch = std::getchar();
  bool f = 0;
  while (!std::isdigit(ch)) {
    f = (ch == '-');
    ch = std::getchar();
  }
  while (std::isdigit(ch)) {
    x = x * 10 + (ch - '0');
    ch = std::getchar();
  }
  return f ? -x : x;
}
template <typename T>
void print(T x) {
  if (x < 0) {
    x = -x;
    std::putchar('-');
  }
  if (x < 10) {
    std::putchar(x + 48);
    return;
  }
  print<T>(x / 10);
  std::putchar(x % 10 + 48);
  return;
}
namespace Solution {
using std::cin;
using std::cout;
using std::deque;
using std::endl;
using std::map;
using std::pair;
using std::queue;
using std::set;
using std::vector;
const int N = 204001, mod = 1e9 + 7;
char s[N], T[N];
int n, tot, lst, cnt, rt[N], ls[N * 50], rs[N * 50], nxt[N];
struct Node {
  int lnk, len;
  map<char, int> mp;
} kk[N * 2];
void insert(int &nw, int L, int R, int pos) {
  if (!nw) {
    nw = ++cnt;
  }
  if (L == R) {
    return;
  }
  int mid((L + R) / 2);
  pos <= mid ? insert(ls[nw], L, mid, pos) : insert(rs[nw], mid + 1, R, pos);
}
int merge(int x, int y, int L, int R) {
  if (!x || !y) {
    return x + y;
  }
  if (L == R) {
    return x;
  }
  int mid((L + R) / 2), nw = ++cnt;
  ls[nw] = merge(ls[x], ls[y], L, mid);
  rs[nw] = merge(rs[x], rs[y], mid + 1, R);
  return nw;
}
void insert(char ch) {
  int cur = ++tot, p = lst;
  kk[cur].len = kk[p].len + 1;
  while (p && !kk[p].mp.count(ch)) {
    kk[p].mp[ch] = cur;
    p = kk[p].lnk;
  }
  if (p) {
    int q = kk[p].mp[ch];
    if (kk[q].len == kk[p].len + 1) {
      kk[cur].lnk = q;
    } else {
      int clo = ++tot;
      kk[clo] = kk[q];
      kk[clo].len = kk[p].len + 1;
      while (p && kk[p].mp[ch] == q) {
        kk[p].mp[ch] = clo;
        p = kk[p].lnk;
      }
      kk[q].lnk = kk[cur].lnk = clo;
    }
  } else {
    kk[cur].lnk = 1;
  }
  insert(rt[lst = cur], 1, n, kk[cur].len);
}
std::vector<int> v[N];
bool query(int ql, int qr, int L, int R, int nw) {
  if (!nw) {
    return 0;
  }
  if (ql <= L && R <= qr) {
    return 1;
  }
  if (qr < ql) {
    return 0;
  }
  int mid((L + R) / 2);
  if (ql <= mid && mid < qr) {
    return query(ql, qr, L, mid, ls[nw]) | query(ql, qr, mid + 1, R, rs[nw]);
  } else if (ql <= mid) {
    return query(ql, qr, L, mid, ls[nw]);
  } else {
    return query(ql, qr, mid + 1, R, rs[nw]);
  }
}
void dfs(int u) {
  for (int i : v[u]) {
    dfs(i);
    rt[u] = merge(rt[u], rt[i], 1, n);
  }
}
void Fakemain() {
  lst = tot = 1;
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i(1); i <= n; ++i) {
    insert(s[i]);
  }
  for (int i(2); i <= tot; ++i) {
    v[kk[i].lnk].push_back(i);
  }
  dfs(1);
  int m;
  scanf("%d", &m);
  while (m--) {
    int l, r, x(1);
    scanf("%d %d %s", &l, &r, T + 1);
    int len = strlen(T + 1);
    int i;
    for (i = 1; i <= len + 1; ++i) {
      nxt[i] = -1;
      for (int j(std::max(0, T[i] - 'a' + 1)), y; j < 26; ++j) {
        y = kk[x].mp[j + 'a'];
        if (y && query(l + i - 1, r, 1, n, rt[y])) {
          nxt[i] = j;
          break;
        }
      }
      x = kk[x].mp[T[i]];
      if (!x || !query(l + i - 1, r, 1, n, rt[x]) || i == len + 1) {
        break;
      }
    }
    while (i && nxt[i] == -1) {
      --i;
    }
    if (!i) {
      puts("-1");
    } else {
      for (int j(1); j < i; ++j) {
        putchar(T[j]);
      }
      putchar(nxt[i] + 'a');
      putchar('\n');
    }
  }
  return;
}
}  // namespace Solution
int main(int argc, char *argv[]) {
  Solution::Fakemain();
  return 0;
}