e-olymp
Problems

Matrix product

Matrix product

prb1322In the forest, Countess Mordvinovoj. Peterhof. 1891.Over the years the artist has developed an acute color vision. Now he can see and transfer brush variability of colors depending on lighting and reflections from nearby objects. Painter writes smooth transitions of green, yellow and grayish shades barrel oil, pine needles and moss. But the subtle coloristic changes are not an end in itself for the artist: he wants them to convey to the viewer's real-life nature. The picture makes the viewer the impression that it is within the forest area, gives to experience the surrounding atmosphere pine thicket.

Given three square matrices A, B, C, each of which has size n x n. Must verify that: A х B = C.

Input

Each test starts the value of n (n500). Followed by three matrices A, B, C, each of which is n rows containing exactly n numbers. Elements of the matrices A and B modulo do not exceed 1000. The final test includes n = 0 and not processed. For example, in the first test should verify that

prb1322-1

Output

For each test, a single line display "YES" or "NO" depending on whether the equation A x B = C or not.

Time limit 1 seconds
Memory limit 64 MiB
Input example
2
1 2
3 4
1 3
2 3
5 9
11 21
2
1 2
3 4
1 3
2 3
5 9
10 21
0
Output example
YES
NO
Source Медведев М.Г. - Зимняя школа в Харькове 2009