Anagrams

Easy

Given two strings A and B, find whether A and B are anagrams of each other or not.

Example 1

A: ”abcd”

B: “dabc”

A & B are anagrams.

Example 2

A: “workattech”

B: “worktattch”

A & B are not anagrams.

Testing

Input Format

The first line contains an integer ‘T’ denoting the number of test cases.

For each test case, the input contains three lines

  • two integers ‘n’ and ‘m’ denoting the size of A and B.
  • string A.
  • string B.

Output Format

For each test case, the output contains a line with 1 if strings are anagrams and 0 otherwise.

Sample Input

4
5 5
apple
pplae
5 4
learn
nerd
4 4
abcd
dabc
10 10
workattech
worktattch

Expected Output

1
0
1
0

Constraints

1 <= T <= 100
1 <= n, m <= 104
Strings should be composed of lowercase English characters.

Editorial Link: Editorial