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>
class Acm {
  struct node {
    unsigned next[26];
    unsigned restart;
    int depth;
    std::vector<unsigned> children, queries;
    std::set<int>* sets[26];
    node(int d) : depth(d) {
      memset(next, 0, sizeof(next));
      for (int i = 0; i < 26; ++i) sets[i] = new std::set<int>();
    }
    ~node() {
      for (int i = 0; i < 26; ++i) delete sets[i];
    }
  };
  std::vector<node> pool;

 public:
  Acm(unsigned n) {
    pool.reserve(n);
    pool.emplace_back(0);
  }
  void insert(const char* str, unsigned qid) {
    int curr = 0;
    pool[0].queries.emplace_back(qid);
    while (*str) {
      int ch = *str++ - 'a';
      if (pool[curr].next[ch] == 0) {
        pool[curr].next[ch] = pool.size();
        pool.emplace_back(pool[curr].depth + 1);
      }
      curr = pool[curr].next[ch];
      pool[curr].queries.emplace_back(qid);
    }
  }
  void compile() {
    std::queue<unsigned> Q;
    for (int i = 0; i < 26; ++i) {
      unsigned x = pool[0].next[i];
      if (x > 0) Q.emplace(x), pool[x].restart = 0;
    }
    while (!Q.empty()) {
      unsigned curr = Q.front();
      Q.pop();
      unsigned r = pool[curr].restart;
      for (int i = 0; i < 26; ++i) {
        int p = pool[curr].next[i];
        if (p > 0) {
          Q.emplace(p);
          pool[p].restart = pool[r].next[i];
        } else
          pool[curr].next[i] = pool[r].next[i];
      }
    }
    for (unsigned i = 1; i < pool.size(); ++i)
      pool[pool[i].restart].children.emplace_back(i);
  }
  void match(const char* str) {
    pool[0].sets[*str - 'a']->emplace(0);
    for (unsigned curr = 0, i = 0; str[i + 1]; ++i) {
      curr = pool[curr].next[str[i] - 'a'];
      pool[curr].sets[str[i + 1] - 'a']->emplace(i + 1);
    }
  }
  template <class Func>
  void dfs(unsigned curr, Func func) {
    for (auto p : pool[curr].children) dfs(p, func);
    for (auto i = 0; i < 26; ++i) {
      for (auto p : pool[curr].children) {
        if (pool[p].sets[i]->size() > pool[curr].sets[i]->size())
          std::swap(pool[p].sets[i], pool[curr].sets[i]);
      }
      for (auto p : pool[curr].children)
        pool[curr].sets[i]->insert(pool[p].sets[i]->begin(),
                                   pool[p].sets[i]->end());
    }
    std::set<int>** sets = pool[curr].sets;
    for (auto q : pool[curr].queries) func(q, pool[curr].depth, sets);
  }
};
struct Query {
  unsigned l, r;
  const char* str;
  int ans;
  char ch;
  Query(unsigned l, unsigned r, const char* s)
      : l(l - 1), r(r - 1), str(s), ans(-1) {}
  void check(int d, std::set<int>** sets) {
    if (ans >= d) return;
    int st = str[d] ? str[d] - 'a' + 1 : 0;
    for (; st < 26; ++st) {
      auto it = sets[st]->lower_bound(l + d);
      if (it != sets[st]->end() && *it <= r) {
        ans = d;
        ch = st + 'a';
        break;
      }
    }
  }
  void print() {
    if (ans < 0)
      puts("-1");
    else {
      for (int i = 0; i < ans; ++i) putchar(str[i]);
      putchar(ch);
      putchar('\n');
    }
  }
};
char base[100008];
char bar[400008];
int main(void) {
  scanf("%s", base);
  int m;
  scanf("%d", &m);
  std::vector<Query> queries;
  Acm acm(200008);
  for (char* curr = bar; m-- > 0;) {
    int l, r;
    int a, b;
    scanf("%d %d %n%s%n", &l, &r, &a, curr, &b);
    acm.insert(curr, queries.size());
    queries.emplace_back(l, r, curr);
    curr += b - a + 1;
  }
  acm.compile();
  acm.match(base);
  auto func = [&queries](unsigned q, int d, std::set<int>** sets) {
    queries[q].check(d, sets);
  };
  acm.dfs(0, func);
  for (auto q : queries) q.print();
  return 0;
}