#K85137. Library Book Management System

    ID: 36575 Type: Default 1000ms 256MiB

Library Book Management System

Library Book Management System

You are given a library with g different genres of books. Initially, each genre i has a number of books given by initial_books[i]. Over d days, the library undergoes several operations. Each operation is represented by two integers: an operation type and a genre identifier. The operation type is defined as follows:

1: A patron borrows a book from the specified genre.
2: A patron returns a book to the specified genre.

The total number of books in the library is updated after each operation. The initial total number of books is given by the formula: \[ total\_books = \sum_{i=1}^{g} initial\_books_i \] After each operation, print the updated total number of books. It is guaranteed that borrow operations will only be applied if there is at least one book available in the genre.

inputFormat

The input is read from standard input (stdin). The first line contains two integers, g and d, where g is the number of genres and d is the number of operations (days).

The second line contains g space-separated integers, representing the initial number of books for each genre.

The following d lines each contain two integers: the first integer is the operation (1 for borrowing, 2 for returning) and the second integer is the genre identifier (1-indexed).

outputFormat

Output d lines to standard output (stdout). Each line should contain a single integer: the total number of books in the library after the corresponding operation.## sample

3 5
5 3 7
1 1
1 3
2 1
1 2
2 2
14

13 14 13 14

</p>