#K40632. Powerful Magic Square Verification

    ID: 26686 Type: Default 1000ms 256MiB

Powerful Magic Square Verification

Powerful Magic Square Verification

You are given an integer n and an n×n grid of integers. Your task is to determine whether the given grid forms a powerful magic square.

A grid is considered a powerful magic square if it satisfies all of the following conditions:

  • Each row contains n unique integers.
  • Each column contains n unique integers.
  • If we denote the sum of the integers in the first row by \(S\), then the sum of the integers in every row and every column is equal to \(S\).

For example, the following 3×3 grid is a powerful magic square:

4 9 2
3 5 7
8 1 6

But if any condition fails, output Not Powerful.

inputFormat

The input is given from standard input (stdin) and has the following format:

n
row1_element1 row1_element2 ... row1_elementn
row2_element1 row2_element2 ... row2_elementn
... 
rown_element1 rown_element2 ... rown_elementn

Here, the first line is an integer n representing the size of the grid, and the following n lines each contain n space-separated integers representing the grid.

outputFormat

Output a single line to standard output (stdout) containing either Powerful or Not Powerful based on whether the grid meets the required conditions.

## sample
3
4 9 2
3 5 7
8 1 6
Powerful