Back
Close
  • 208

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

A magic square is a n×n square grid (where n is the number of cells on each side) filled with distinct positive integers in the range 1, 2 …, such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal. The sum is called the magic constant or magic sum of the magic square. Print MAGIC if the given square is magic or else MUGGLE.
Input
Line 1 : n
n lines : A line of the square
Output
Line 1 : MAGIC or MUGGLE
Constraints
Example
Input
3
2 7 6
9 5 1
4 3 8
Output
MAGIC

A higher resolution is required to access the IDE