#K95762. Mars Resource Redistribution

    ID: 38936 Type: Default 1000ms 256MiB

Mars Resource Redistribution

Mars Resource Redistribution

You are given a simulation problem where you need to manage the redistribution of resources among different regions on a Martian base. Each region initially has a certain number of resources. You will be given q queries, and there are two types of queries:

  • Type 1: 1 a b x — Transfer x resources from region a to region b. This operation decreases the resources at region a and increases the resources at region b.
  • Type 2: 2 a — Output the current number of resources at region a.

Note that the queries are processed in the given order. In the input, the number of regions is denoted by \( r \) and the number of queries by \( q \). The initial resources of the regions and the queries follow accordingly.

inputFormat

The first line contains two integers \( r \) and \( q \), representing the number of regions and the total number of queries.

The second line contains \( r \) integers, where the \( i^{th} \) integer represents the initial resources in region \( i \).

The next \( q \) lines describe the queries. Each query is in one of the following two formats:

  • 1 a b x — Transfer operation: subtract \( x \) from region \( a \) and add \( x \) to region \( b \).
  • 2 a — Query operation: output the current resources in region \( a \).

outputFormat

For each query of the second type (2 a), output the current number of resources in region \( a \) on a separate line. If there are no queries of type 2, output nothing.

## sample
2 1
10 20
1 1 2 5