stral Reflection
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

This is the easy version of Problem M. abushii Omoi. It's guaranteed that in this version w = 1 for all talents.

In event Unn, mreconciled Stars, some meteorites fell on Teyvat and confused people's minds. In order to protect the people of Teyvat, Mona needs to clean up these meteorites.

Teyvat can be represented by a line [1, n], and meteorites can be represented by some points in this line. For clearing meteorites, Mona can use some types of her talents. A talent can be represented by three integers l, r, w, which means Mona can spend w Power clearing all meteorites in [l, r] by using this talent. At the beginning, Mona has no talent, but she will learn gradually.

Mona wants to spend as few Power as possible. For each wave of meteorite shower, Mona wants to know if she can clean up all the meteorites by using the talents she has mastered by then, and if yes, what the minimum possible Power it requires to clean all of them. More specifically, there will be two types of operation:
  • 1 l r w: Mona learns a new talent to clear all meteorites in [l, r] with w Power.
  • 2 k a_1 a_2 ... a_k: There are k meteorites in point . Mona needs to calculate the minimum power she needs to spend to clear these k meteorites, or point out that some of meteorites are impossible to clear.
Note: Meteorites from the previous wave will be cleared automatically, no matter if Mona succeeds in clearing all of them or not.

输入描述:

The first line contains two integers n, m () --- the size of Teyvat and the number of operations.

In the following m lines, each line will be in one of the following format as described in the statement:

1 l r w (, w = 1)
2 k a_1 a_2 ... a_k (, )

All of input are integers.

It is guaranteed that the sum of k for all operations does not exceed .

输出描述:

For each operation of type 2, output the minimum power Mona needs to spend to clear these meteorites. If some of meteorites are impossible to clear, output -1.
示例1

输入

复制
10 5
1 1 3 1
2 1 2
2 2 2 4
1 3 5 1
2 2 2 4

输出

复制
1
-1
2

备注:

In the first example, operations are explained as follows:

Operation 1: Mona learns a new talent to clear all meteorites in [1, 3] with 1 Power.
Operation 2: There is 1 meteorite in point 2. Mona can spend 1 Power using talent [1, 3] to clear up it.
Operation 3: There is 2 meteorites in point 2, 4 respectively. Mona can spend 1 Power using talent [1, 3] to clear up meteorite in point 2, but she can't clear up meteorite in point 4.
Operation 4: Mona learns a new talent to clear all meteorites in [3, 5] with 1 Power.
Operation 5: There is 2 meteorites in point 2, 4 respectively. Mona can spend 2 Power totally using talent [1, 3] and [3, 5] to clear up them.