Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

2782.   I am Lord Voldemort
Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 2337   Accepted Runs: 1184    Multiple test files

If you have ever read Harry Potter, you would know that the evil and powerful wizard, Lord Voldemort, create this name by permuting his original name, "Tom Marvolo Riddle", to "I am Lord Voldemort".

Write a program to check whether it is possible to transform a given word to another by permuting its letters.


The first line is an integer T, the number of test cases. Following T lines each contains two words separated by spaces.


For each test case, Output on a line "Yes" if it is possible to do the transformation, otherwise output "No" instead.


  • Permuting a word is to change the order of its letters, but no new letters can be added and no original letters can be deleted. For example, one can transform "aabc" to "abca", but not to "bac", "abc", "aabca", "aacbb".
  • Words will contain letters only('a'-'z', 'A'-'Z').
  • A word won't contain any white spaces in itself.
  • The given two words will not be the same.
  • You should ignore case when comparing words, i.e. 'a' is the same as 'A', 'b' is the same as 'B', etc.
  • Constraints

  • The length of any given word is greater than 0 and no larger than 50.
  • Sample Input

    TomMarvoloRiddle  IamLordVoldemort
    stop pots
    abbc bac
    InternetAnagramServer IRearrangementServant

    Sample Output


    Source: The 5th UESTC Programming Contest Preliminary
    Submit   List    Runs   Forum   Statistics

    Tianjin University Online Judge v1.3.0
    Maintance:G.D.Retop. Developer: SuperHacker, G.D.Retop