Universal Cup Judging System

Universal Cup

时间限制: 4.0 s 内存限制: 1024 MB 总分: 100 难度: [显示] 可 Hack ✓
统计

Oblivionis took one final look at home before departing, resolutely deciding to leave the past behind. She wished that the magic of time could reshape her now chaotic heartbeat into a healthy, harmonious rhythm once again. But before she could truly forget everything, a question lingered in her mind: What if the events of the past had unfolded in a different order? Would the outcome have been different, and would her understanding of it have changed as well?

Given an $n \times n$ matrix $A$ over $\mathbb{F}_{998244353}$, consider how many matrices $B$ commute with $A$, i.e., how many matrices satisfy $AB = BA$. It can be proven that there exists a positive integer $k$ such that the number of such matrices is $998244353^k$. Please determine the value of $k$.

Input

The first line of the input contains a single integer $n$ ($1 \le n \le 500$).

The next $n$ lines describe the matrix $A$. The $i$-th line of these lines contains $n$ integers $A_{ij}$ ($0 \le A_{ij} < 998244353$), indicating the matrix $A$.

Output

Output a single line with a single integer, indicating the answer, $k$.

Examples

Input 1

3
1 2 3
4 5 6
7 8 9

Output 1

3

Input 2

3
1 1 0
0 1 0
0 0 1

Output 2

5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.