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.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

madhursengar24 | 86 |

PiyushPandey4 | 617 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 448 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.