musabgultekin/TACO huggingface dataset:
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".

Difficulty: VERY_HARD
Tags: String algorithms

Data structures
Skill types: Data structures

Starter code:

Solutions:
Problem

A-chan, Rika-chan, and Hart-kun came to visit the condominium.
The three decided to sneak into a room where they could manage the electricity in all the rooms and play a trick.

This condominium has the shape of n cubes lined up in a row.
Each cube has one side length increasing by 1 from the west (1,2,3, ..., n), the i-th cube has i floors, and each floor has i x horizontal rooms. There is.
The west side of the second and subsequent cubes borders the east side of one west cube, and the south side of all cubes faces a straight road.



<image>



At first, all rooms have electricity.
Each of the three took the following actions.


* A-chan turned off the lights in all the kth rooms from the west.
* Licca turned off the lights in all the kth rooms from the south.
* Hart turned off the lights in all rooms on the k floor.



Find the number of rooms that are lit after such mischief has been done m times.

Constraints

* 1 ≤ n, m ≤ 50000
* 0 ≤ qi ≤ 2
* 1 ≤ ki ≤ 2 × 109
* The same action can only be given once

Input


n m
q1 k1
...
qm km


All inputs are given as integers.
The number n of cubes and the number m of actions are given in the first line.
The numbers q and k of the person who acted on the second and subsequent lines m are given.

When qi is 0, it means that A-chan, when it is 1, it means that Rika-chan, and when it is 2, it means that Hart-kun has acted.

The three may try to turn off the lights in places where there is no room.

Output

Output the number of rooms with electricity in one line.

Examples

Input

3 1
0 4


Output

27


Input

3 2
2 2
2 3


Output

14

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions: