Given an array of distinct +ve integers A[] and a number x, your task is to find the number of pairs of integers in the array whose XOR is equal to x.

Examples:

```
Input : A[] = {5, 4, 10, 15, 7, 6}, x = 5
Output : 1
Explanation : (10 ^ 15) = 5
Input : A[] = {3, 6, 8, 10, 15, 50}, x = 5
Output : 2
Explanation : (3 ^ 6) = 5 and (10 ^ 15) = 5
```

**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 . The first line of each test case is an integer N denoting the size of the array A. In the next line are N space separated values of the array A. In the next line is an integer x.

**Output:**

For each test case output in a new line the number of pairs of integers in the array whose XOR is equal to x.

**Constraints:**

1<=T<100

1<=N<=100

1<=A[] <=1000

**Example:
Input:**

2

6

3 6 8 10 15 50

5

6

5 4 10 15 7 6

5

2

1

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.

vamsikrishna55 | 122 |

UrGuru | 117 |

Vagesh Verma | 112 |

chaolinyu | 96 |

Akhil varma | 93 |

abducodes | 634 |

harshtyagi36 | 302 |

highway_to_hell | 252 |

rajeswarii | 248 |

Akhil varma | 246 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.