#K50807. Taco Tuple Commands

    ID: 28946 Type: Default 1000ms 256MiB

Taco Tuple Commands

Taco Tuple Commands

You are given a list of n tuples, each containing m integers. Your task is to process q commands. There are two types of commands:

  • UPDATE t p v: Update the tuple at position t (1-indexed) by setting its p-th element (1-indexed) to value v.
  • QUERY t: Print the current state of the tuple at position t (1-indexed). The tuple should be printed as m space-separated integers.

The process involves both updates and queries. You need to output the result of every query command.

Constraints:

1 ≤ t ≤ n, 1 ≤ p ≤ m

All modifications must be reflected in subsequent queries.

The underlying idea can be mathematically formalized as follows:

\( A = [a_{ij}]_{n \times m} \) where for an update command, \( a_{t,p} \) is replaced with \( v \), and for a query command, the \( t \)-th row of \( A \) is printed.

inputFormat

The first line contains two integers n and m, the number of tuples and the number of integers in each tuple, respectively.

Then follow n lines, each containing m space-separated integers representing the tuples.

The next line contains the integer q, the number of commands.

Each of the following q lines contains a command in one of the two formats:

  • UPDATE t p v
  • QUERY t

Note: Indices t and p are 1-indexed.

outputFormat

For each QUERY command, print a line containing the corresponding tuple's integers separated by single spaces.

## sample
3 4
1 2 3 4
5 6 7 8
9 10 11 12
5
QUERY 1
UPDATE 1 2 20
QUERY 1
UPDATE 3 4 40
QUERY 3
1 2 3 4

1 20 3 4 9 10 11 40

</p>