Rows and columns P28318


Statement
 

pdf   zip

thehtml

Write a program that reads a matrix, and afterwards prints the rows, the columns and the elements that are asked for.

Input

Input consists of a matrix followed by a sequence of questions about the matrix. The matrix is described with two natural numbers n > 0 and m > 0, followed by n lines with m integer numbers each one. Every question begins with the word “row”, “column” or “element”. If the word is “row”, it is followed by the number of a row. If the word is “column”, it is followed by the number of a column. If the word is “element”, it is followed by the number of a row and the number of a column. All the given numbers of row and of column are correct, and start with 1.

Output

For every question, print the row, the column, or the element asked for.

Public test cases
  • Input

    4 6
    5 7 6 4 1 2
    2 8 1 3 8 8
    0 1 2 9 2 1
    6 5 4 3 2 1
    
    row 4
    column 2
    element 1 2
    row 1
    

    Output

    row 4: 6 5 4 3 2 1
    column 2: 7 8 1 5
    element 1 2: 7
    row 1: 5 7 6 4 1 2
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java Python