
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
Given a positive integer \( n \geq 2 \), consider the matrices
\[ 
A = \begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{n1} & a_{n2} & \cdots & a_{nn}
\end{pmatrix}, \quad 
B = \begin{pmatrix}
b_{11} & b_{12} & \cdots & b_{1n} \\
b_{21} & b_{22} & \cdots & b_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
b_{n1} & b_{n2} & \cdots & b_{nn}
\end{pmatrix}
\]

and they satisfy
\[
\{a_{ij} \mid 1 \leq i, j \leq n\} = \{b_{ij} \mid 1 \leq i, j \leq n\} = \{1, 2, \ldots, n^2\}.
\]

An operation can be performed on \( A \) as follows: select two numbers located in the same row or column and swap their positions, while the remaining \( n^2 - 2 \) numbers remain unchanged. This operation is called a single swap. Determine the smallest positive integer \( m \) such that for any \( A \) and \( B \), \( A \) can be transformed into \( B \) by performing no more than \( m \) swaps.

Present the answer in LaTex format: \boxed{Your answer}
user