#K53897. Taco Reordering Problem

    ID: 29633 Type: Default 1000ms 256MiB

Taco Reordering Problem

Taco Reordering Problem

You are given two arrays, \( A \) and \( B \), each of length \( N \). You can reorder the elements of \( A \) arbitrarily. After reordering, for every index \( i \):

  • If \( B[i] \) is even, then \( A[i] \) must satisfy \( A[i] \le B[i] \).
  • If \( B[i] \) is odd, then \( A[i] \) must satisfy \( A[i] \ge B[i] \).

Your task is to determine whether there exists a reordering of \( A \) that satisfies these conditions. If such a reordering exists, print YES; otherwise, print NO.

Note: Input is read from standard input and output to standard output.

inputFormat

The input begins with an integer \( T \) indicating the number of test cases. Each test case is described as follows:

  1. An integer \( N \) representing the size of the arrays.
  2. A line with \( N \) space-separated integers representing the array \( A \).
  3. A line with \( N \) space-separated integers representing the array \( B \).

All input is read from standard input.

outputFormat

For each test case, output a single line containing YES if it is possible to reorder \( A \) to satisfy the condition with \( B \), otherwise output NO.

All output should be printed to standard output.

## sample
2
5
1 2 3 4 5
5 4 3 2 1
3
7 8 9
6 5 4
YES

NO

</p>