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
alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
k = input()
for n in range(k):
    z = raw_input()
    a = list(z)
    b = []
    for c in a:
        if c not in b:
            b.append(c)
    b.sort()
    def palindrome(string):
        z = 0
        for b in range(len(string)):
            z -= 1
            if string[b]==string[z]:
                flag = 0
            else:
                flag = 1
                break
        if flag == 0:
            return True
        else:
            return False
    if b == alpha and palindrome(z):
        print "palingram"
    else:
        if b == alpha:
            print "pangram"
        elif palindrome(z):
            print "palindrome"

        else:
            print "none"