Anagrams P71916


Statement
 

pdf   zip

html

Two sentences (or two words) are anagrams if one can be obtained from the other one simply reordering their letters (forgetting the spaces and the punctuation symbols) .

For instance, “ROME” and “MORE” are anagrams. Also, “AVE MARIA, GRATIA PLENA, DOMINUS TECUM” and “VIRGO SERENA, PIA, MUNDA ET IMMACULATA” are anagrams.

Write a program that prints if the pairs are or are not anagrams.

Input

Input starts with a number n After, each sentence is given in a line ending in a dot. The sentences may contain uppercase letters, spaces and punctuation symbols (but only a dot in the end).

Output

For each pair of sentences, print “YES” if they form an anagram and “NO” otherwise.

Public test cases
  • Input

    3
    ROME.
    MORE.
    AVE MARIA, GRATIA PLENA, DOMINUS TECUM.
    VIRGO SERENA, PIA, MUNDA ET IMMACULATA.
    ARMY.
    MARY.
    

    Output

    YES
    YES
    YES
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C++ Python