Given two integer numbers, whenever the bits of the first number is set i.e. 1, negate the bits of the second number leaving the rest bits of the second number unchanged.

**Input: **

The first line of input contains integer **T** denoting the number of test cases. For each test case, there are two integer inputs i.e.** f** the first number and **s** the second number whose bits need to be changed according to the set bits of **f**.

**Output: **

For each test case, the output is the integer **s**.

**Constraints:**

1<=T<=100

1<=f,s<=1000

**Example:**

**Input:**

2

2 5

1 3

**Output:**

7

2

**Explanation:**

**1**. 2 is represented as 10 in binary and 5 is represented as 101.Hence negating the 2nd bit of 5 from right, thus the new number becomes 7 i.e. 111.

**2.**1-1 and 3-11 in binary, thus negating 1st bit of 3 from right we get 10 i.e. 2.

Author: Vanshika_pec

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.

d_Coder00 | 134 |

dungeon_master1299 | 126 |

Astikeysingh | 120 |

rajendrashekhawat063 | 115 |

kaustavbhattachaarya | 111 |

Pulkit__Sharma__ | 646 |

Anirban166 | 531 |

abducodes | 501 |

Found_me | 454 |

Yo_Nehru | 404 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.