This page is still under construction.

Parts of this page are still being built. What you see may change.

Numbersrebmun

Time limit1sMemory limit128 MB

Summary
Map each letter of a company name to its phone keypad digit, then check whether the resulting digit string reads the same forwards and backwards.
Level

Easy2 of 10

Topics
String, Two pointers, Implementation
Solved
No attempts yet

Problem

Anna and Bob are starting a new high-tech company, and they want a memorable name. They love palindromes — words that read the same forwards and backwards, like their own names — but they cannot come up with a catchy company name that is also a palindrome.

So they settle for the next best thing: a phone number that is a palindrome. They want customers to be able to dial the company by spelling its name on a phone keypad, so the digits produced by typing the company name must form the phone number. On a standard phone keypad, the letters are grouped like this:

KeyLetters
2A B C
3D E F
4G H I
5J K L
6M N O
7P Q R S
8T U V
9W X Y Z

Given a company name, decide whether the phone number obtained by mapping each letter to its keypad digit is a palindrome. Letters may be uppercase or lowercase; the mapping ignores case.

Input

The first line contains an integer nn, the number of company names that follow. Each of the next nn lines contains one company name: a string of at most 20 letters, each either uppercase or lowercase.

Output

For each company name, print a single line containing YES if its phone number is a palindrome, or NO otherwise.

Examples1

  1. Example 1

    Input
    2
    ANBOBNA
    iAmACoolCompany
    
    Expected output
    YES
    NO