eolymp
bolt
Try our new interface for solving problems
Problems

Matrix product

Matrix product

In the forest Countess Mordvinovoj, Peterhof, 1891

prb1322.gif

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

Given three square matrices A, B, C, each of size n * n. Verify for equality A * B = C.

Input

Each test case starts with the value of n (n500). It is followed by three matrices A, B, C, each of which has n rows containing exactly n numbers. The elements of the matrices A and B do not exceed 109 by absolute value. The final test contains n = 0 and is not processed. For example, in the first test case, you should verify that

prb1322_1.gif

Output

For each test case, print a single line with "YES" or "NO" depending on whether the equation A * B = C or not.

Time limit 1 second
Memory limit 128 MiB
Input example #1
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 #1
YES
NO
Author Mykhailo Medvediev
Source 2009 Kharkiv Winter School