A number is said to be a magic number, if the sum of its digits are calculated till a single digit recursively by adding the sum of the digits after every addition. If the single digit comes out to be 1,then the number is a magic number.

**Input:**

First line of input contains a single integer T, denoting the number of test cases. First line of each test case contains an integer N.

**Output:**

For each of the test case print whether the number N is "**Magic" **or "**Not Magic"**

**Constraints:**

1 <= T <= 10^{5}

1 <= N <= 10^{5}

**Example:**

**Input:**

2

1234

67

**Output**

Magic

Not Magic

**Explanation:**

1234 sums up to 10 which sums upto 1 so its a Magic Number.

67 sums up to 11 which sums upto 2 so its not a Magic Number

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

geetyadav | 82 |

hari32147 | 76 |

AdityaRaj9 | 75 |

yashrana1 | 74 |

giavytrinh98 | 64 |

abducodes | 839 |

harshtyagi36 | 417 |

vamsikrishna55 | 323 |

sandipbhaumik | 321 |

Akhil varma | 314 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.