cswork / OAOpen practice workspace

Goldman SachsOA #23

Bitwise XOR Subsequences

Estimated MediumJudge-ready

Topics (AI-labelled)HashingSubsequences

Find the longest subsequence of the array such that the bitwise XOR of every pair of adjacent chosen elements equals k. A subsequence of length 1 is always valid.

Input

The first line contains n (1..100000), followed by n lines, each with one arr[i] (0..10^6), and a final line with k (0..10^6).

Output

Output the length of the longest valid subsequence.

Example 1

Input:

4
1
2
3
4
3

Output:

2

Example 2

Input:

1
5
0

Output:

1

Example 3

Input:

4
2
2
2
2
0

Output:

4

Editorial

Loading solution…