Problem 1

Gramanas

The problem

An anagram is formed by rearranging the letters of a word. The aim of this problem is test whether a string is an anagram of a word or not. No word (or string) will have have more than 50 characters.

Input

The input will consist of a word on one line. The following line will contain a number, n (1 <= n <= 30000), of strings to be tested.

Output

For each test string, the program should output a single line. If the test string is identical to the source string, the line should read IDENTICAL, if it is an anagram, it should read ANAGRAM otherwise it should read NOT AN ANAGRAM.

Example

Input

cares
5
scare
races
cares
another
acres

Output

ANAGRAM
ANAGRAM
IDENTICAL
NOT AN ANAGRAM
ANAGRAM