Control C401C

Your task is to write a program that starts reading and printing a matrix of integers n×mn \times m. Afterwards, for each pair of natural numbers jj and kk given, print the previous matrix with the columns jj and kk swapped. The columns are counted from 0 to m1m - 1.

Using the definition

    typedef vector<vector<int> > Matrix;

your program must implement and use the function

    void swap(Matrix& mat, int j, int k);

that, given a matrix |mat| and the natural numbers jj and kk, swaps the columns jj and kk of |mat|. The indices jj and kk will always be between 0 and the number of columns of |mat| minus one.

Input

The input starts with the size n>0n > 0 and m>0m > 0 of the matrix, followed by nn lines with mm elements each one, followed by a sequence of pairs jj, kk. Each jj and each kk is between 0 and m1m - 1.

Output

Your program must print the sequence of matrices composed of the read matrix, followed by the resulted matrix of each swap. Notice that print lines with five dashes to separate the matrices, at the beginning and in the end.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:32:54.488Z

© Jutge.org, 2006–2026.
https://jutge.org