eolymp
bolt
Try our new interface for solving problems
Problems

Оксюморон

Оксюморон

Three square matrices of equal size are given. Verify that the third matrix is the product of the first and the second (in that order).

Input

Состоит из нескольких тестов. Каждый тест начинается с размера матриц n (1n500). Далее следует описание трёх матриц, каждая из которых описывается n строками по n целых чисел каждая. Все входные числа не превосходят 109. Последний тест содержит n = 0 и не обрабатывается.

Output

Print YES if the third matrix is the product of the first and the second and NO otherwise.

Time limit 1 second
Memory limit 122.49 MiB
Input example #1
2
1 0
0 1
1 0
0 1
1 0
0 1
2
1 0
0 1
1 0
0 1
1 0
0 0
0
Output example #1
YES
NO