Given a number **N**, you need to write a program that finds the sum of digits of the number till the number becomes a single digit and then check whether the number is Prime/Non-Prime.

Example:

```
Input : 5602
Output: No
Step 1- 5+6+0+2 = 13
Step 2- 1+3 = 4
4 is not prime
Input : 56
Output : Yes
Step 1- 5+6 = 11
Step 2- 1+1 = 2 hence 2 is prime
```

**Input:**

First line of the input contains an integer **T**, denoting the number of test cases. Then **T **test case follows. The only lone of each testcase contains the integer **N**.

**Output:**

For each test case print "**P**" if the resultant is prime and "**NP**" if the number is Non-prime.

**Constraints:**

1<=T<=10^{3}

1<=N<=10^{5}

**Example:
Input:**

2

1903

25

NP

P

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.

hardikJain5 | 258 |

CodeBuddy | 250 |

bhatabhi554 | 232 |

Akkki111 | 197 |

clone | 174 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1127 |

mazumderrohit8 | 1124 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4591 |

Quandray | 4444 |

Login to report an issue on this page.