#K6491. Bitwise AND Pair Existence

    ID: 32080 Type: Default 1000ms 256MiB

Bitwise AND Pair Existence

Bitwise AND Pair Existence

Given two arrays A and B each containing n integers, determine if there exists at least one pair of integers \(a\) from A and \(b\) from B such that their bitwise AND, \(a \& b\), is nonzero.

Input: The first line contains an integer \(n\) (the number of elements in each array). The second line contains \(n\) integers representing the array A. The third line contains \(n\) integers representing the array B.

Output: Output a single line containing YES if there exists at least one pair \((a, b)\) such that \(a \& b \neq 0\), otherwise output NO.

inputFormat

The input is read from standard input and is structured as follows:

  • The first line contains an integer \(n\) representing the number of elements in each array.
  • The second line contains \(n\) space-separated integers representing the array A.
  • The third line contains \(n\) space-separated integers representing the array B.

outputFormat

The output is written to standard output. Print a single line containing YES if there exists at least one pair of integers (one from each array) such that their bitwise AND is nonzero; otherwise, print NO.

## sample
3
1 2 3
4 5 6
YES