#C11021. Check if Word Pairs are Anagrams

    ID: 40292 Type: Default 1000ms 256MiB

Check if Word Pairs are Anagrams

Check if Word Pairs are Anagrams

You are given a list of N words and M queries. Each query consists of two integers i and j (with $1 \le i, j \le N$). For each query, determine whether the i-th word is an anagram of the j-th word.

An anagram is a word formed by rearranging the letters of another, using all the original letters exactly once.

Input/Output Example:

Input:
4
listen silent rock cork
3
1 2
3 4
1 3

Output: True True False

</p>

Your task is to implement a solution that reads from standard input and writes to standard output.

inputFormat

The input is given via standard input and consists of the following:

  1. An integer N representing the number of words.
  2. A line with N words separated by spaces.
  3. An integer M representing the number of queries.
  4. M lines, each containing two space-separated integers i and j (1-based indices) representing a query.

outputFormat

For each of the M queries, output True if the two words are anagrams of each other, and False otherwise. Each output should be printed on a new line.

## sample
4
listen silent rock cork
3
1 2
3 4
1 3
True

True False

</p>