Given two arrays **A** and **B** of equal size **N**, the task is to find if given arrays are equal or not. Two arrays are said to be equal if both of them contain same set of elements, arrangements (or permutation) of elements may be different though.

**Note :** If there are repetitions, then counts of repeated elements must also be same for two array to be equal.

**Input:**

The first line of input contains an integer** T** denoting the no of test cases. Then **T** test cases follow. Each test case contains 3 lines of input. The first line contains an integer **N **denoting the size of the array. The second line contains element of array **A[]**. The third line contains elements of the array **B[]**.

**Output:**

For each test case, print **1** if the arrays are equal else print **0**.

**Constraints:**

1<=T<=100

1<=N<=10^{7}

1<=A[],B[]<=10^{18}

**Example:
Input:**

2

5

1 2 5 4 0

2 4 5 0 1

3

1 2 5

2 4 15

**Output:**

1

0

**Explanation:**

**Testcase1:**

Input : A[] = {1, 2, 5, 4, 0}; B[] = {2, 4, 5, 0, 1};

Output : 1

**Testcase2:**

Input : A[] = {1, 2, 5}; B[] = {2, 4, 15};

Output : 0

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

the_coder95 | 465 |

thanuvinu94 | 388 |

adityasuman2025 | 305 |

Senbonzakura_Kageyoshi | 297 |

PrakharBansal1 | 274 |

the_coder95 | 1691 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 1064 |

samay_kam_hai | 724 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.