For Turbo C++ Users : Read the following document before attempting the question :  

Problem Description

N-Boy is very eccentric when it comes to strings. These days, he spends most of his time studying palindromes and pangrams (for his IP assignment at IIITD). For those of you who don’t know, a palindrome is a word or a statement which can be read the same way, forward or backward, and a pangram is a word or a statement containing all letters of the English alphabet.
Now, he is given a set of strings, and he wants to segregate them into palindromes, pangrams and palingrams, which are palindromic pangrams. Unfortunately, he is unable to do so, and has asked you for help.


Input
The first line consists of a single integer T, denoting the number of test cases.
Each test case consists of a string S of lowercase English characters. 

Output
For each test case, output a single line containing a string(without quotes) as follows:

 If the string is only a palindrome, print ‘palindrome’.
 If the string is only a pangram, print ‘pangram’.
 If it is a palingram, print ‘palingram’. 
 Else, print ‘none’. 


Constraints

1 ≤ T ≤ 1000
1 ≤ |S| ≤ 1000

 

Example
Input:
3
abba
abcdefghijklmnopqrstuvwxyz
qwerty

Output:
palindrome
pangram
none
#Enter your code here
import sys 
a=set('abcdefghijklmnopqrstuvwxzy')
sys.stdin.readline()
f=sys.stdin.readlines()
for i in f:
	i=i.strip()
	if i[::-1]==i and set(i)==a:print 'palingram'
	elif i[::-1]==i:print 'palindrome'
	elif set(i)==a:print 'pangram'
	else:print 'none'