LearnToCP
Sign in

Navigation

HomeRoadmapProblemsAbout Us

Theory

Contest Knowledge
Selecting an IDE
Basics
Your First ProgramData types and IOC++ syntaxModuloFunctionsVectorsMatricesTime Complexity
Sorting
SortingCounting sortRadix Sort
Optimization Techniques
Two PointersSum of numbers 1 to nPrefix sumBinary SearchGreedyBinary Search FunctionsBinary Search by AnswerDivide and Conquer
Binary Numbers
Binary NumbersNumbers in codeBitwise OperationsBitmasks
Math
Binary ExponentiationPrime NumbersPrime FactorizationGCD and LCMSieve of EratosthenesModified Sieve
Data Structures
StringsStackQueueMapsSetsPriority QueueCustom Criteria for FunctionsSegment TreesFenwick TreesSparse TablesUnion Find
Combinatorics
Addition PrincipleMultiplication PrincipleCombinatoric ObjectsInclusion Exclusion Principle
Geometry
Geometry BasicsVectorsCross and Dot ProductLinesPolygonsAnglesPoint in PolygonDistances and Intersection PointsConvex HullCircles
Recursion
PointersRecursionGenerating Combinatoric Objects
Dynamic Programming
About DPTree DPBitmask DPDigit DP
Graph Theory
GraphsDFS and BFSShortest PathsTreesTopological SortingDijkstra's AlgorithmMinimum Spanning TreesShortest Path Algorithms
Advanced Graph Theory
BiconnectivityStrongly Connected ComponentsBipartite GraphGraph FlowAugmenting PathsFlow - Minimum Cut DualityHeavy-Light DecompositionCentroid Decomposition
Advanced Data Structures
2D and 3D Segment TreesLazy PropagationImplicit Segment TreesPersistent Segment TreesLowest Common AncestorTrieBalanced Binary Search TreesMo's Algorithm

Anagram

EasyProblem #28
Time LimitMemoryInputOutputTAGS
1 s64 MBstdinstdout
#strings

Only the letters matter.

Two phrases are anagrams if one can be turned into the other by rearranging its letters. Characters that are not letters - spaces and punctuation - are ignored completely.

Your task is to check, for each given pair of phrases, whether they are anagrams.

Input

First line of input will be a single integer t - the number of testcases.
Each testcase consists of two lines, one phrase per line. The phrases are made of lowercase English letters, spaces and punctuation marks (such as . , ! ? ' -).

Output

For every testcase print YES if the two phrases are anagrams, and NO otherwise.

Example

Input
2
panta redovno zakasni
neopravdan izostanak
oni su skrsili vagu
suvisni kilogrami
Output
YES
NO

In the first testcase both phrases use exactly the letters of "neopravdan izostanak". In the second the letter counts differ.

Constraints

1≤t≤100
Each line has at most 105 characters.


This problem was adapted, with permission, from Anagram, authored by Društvo matematičara Srbije and Fondacija Petlja.

Submit your solution

Sign in to submit your solution and track your progress.

Sign in