Inverse

The only way for Neo to escape from the Matrix is to compute its
inverse, which will cause the Matrix to cancel itself out. However, the
Matrix is large and Neo does not know of any efficient algorithm for
computing its inverse. Fortunately, Neo has gained access to the
computer mainframe where several backup copies of the Matrix are stored.
Neo knows that one of these copies is the inverse of the Matrix, but he
does not know which one. Help Neo find the inverse.

Input

The input consists of several test cases. Each test case starts with a
number 2 ≤ n ≤ 1000, the dimension of the Matrix. The next n lines
contains n integers each, representing the Matrix itself. The next 3n
lines also contain n integers each, representing three matrices that are
candidates for the inverse.

Output

For each test case, your program must print "1", "2", or "3" on a single
line, depending on which of the three candidate matrices corresponds to
the inverse of the Matrix.

Observation

Tthe inverse of an n × n matrix M is an n × n matrix M⁻¹ such that
M ⋅ M⁻¹ = I_(n), where I_(n) is the n × n identity matrix.

Problem information

Author: Anders Jonsson

Generation: 2026-01-25T21:30:55.942Z

© Jutge.org, 2006–2026.
https://jutge.org
