#C6235. Replace Value in Matrix

    ID: 49973 Type: Default 1000ms 256MiB

Replace Value in Matrix

Replace Value in Matrix

You are given a matrix \(A\) with \(n\) rows and \(m\) columns. Your task is to replace every occurrence of an integer \(x\) in the matrix with another integer \(y\).

The problem is defined as follows:

Given an \(n \times m\) matrix, find all elements equal to \(x\) and substitute them with \(y\). Finally, print the modified matrix.

Note: The input and output are handled through standard input (stdin) and standard output (stdout).

inputFormat

The first line contains two integers \(n\) and \(m\), representing the number of rows and columns of the matrix, respectively.

The next \(n\) lines contain \(m\) integers each, representing the matrix \(A\).

The last line contains two integers \(x\) and \(y\): the value to be replaced and the replacement value.

outputFormat

Output the modified matrix. Each row should be printed on a separate line with the elements separated by a single space.

## sample
3 3
1 2 3
4 1 6
7 8 1
1 9
9 2 3

4 9 6 7 8 9

</p>