Sums without a module#5294

Sums without a module

3 seconds
64 megabytes
Very easy

Participants of a training camp arrive in groups and need to be accommodated in a hotel. The hotel administrator assigns the -th group to rooms numbered from l_i to r_i inclusive, with one person per room. Thus, the -th group consists of r_i - l_i + 1 people. However, the rooms have a strict capacity limit: each can accommodate at most k-1 people. If a -th person is assigned to a room, all current occupants, including the new arrival, become upset and leave.

Inspired by this effective settlement method, the administrator decided to apply a similar approach to meal organization (breakfasts, lunches, and dinners) during the camp. For each meal, only participants from rooms numbered from s_j to t_j inclusive are invited to the -th meal. Your task is to determine for each meal how many portions need to be prepared.

Input

The first line contains three natural numbers: the number of rooms (1 \le n \le 100000), the room capacity limit (2 \le k \le 5), and the number of events (1 \le m \le 100000) that occurred during the camp.

The following lines each describe an event in chronological order, one per line. Each event is represented by three integers. The arrival of a new group is described as "1 " (1 \le l \le r \le n), where and specify the range of room numbers for accommodation. A meal event is described as "2 ", where and (1 \le s \le t \le n) specify the range of room numbers invited to the meal.

Output

For each meal event, output the number of participants who will be eating, each on a separate line.

Examples

Example 1

Loading
Loading