Given two numbers x and y, and a range [l, r] where 1 <= l, r <= 32. The task is consider set bits of y in range [l, r] and set these bits in x also.

For example, if x = 10, y = 13, l = 2, r = 3, the program should change x to 14. Binary representation of 10 is 1010 and that of y is 1101. There is one set bit in y at 3’rd position (in given range). After we copy this bit to x, x becomes 1110 which is binary representation of 14.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Each test case contains space separated values of x, l, r and y in a single line.

**Output:**

Print modified value of x.

**Constraints:**

1 ≤ T ≤ 50

1 ≤ x ≤ 10000

1 ≤ l, r ≤ 32

1 ≤ y ≤ 10000

**Example:**

**Input:**

2

44 1 5 3

16 1 3 2

**Output:**

47

18

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.

mantan_g | 267 |

tushki | 198 |

aksht7 | 182 |

ayush1101 | 128 |

namansharmacse17 | 110 |

ARUN_PUNDIR | 730 |

manishgupta8497 | 627 |

AMAN__JAIN | 625 |

Abhimanyu_kumar | 562 |

AJ786 | 541 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4584 |

Login to report an issue on this page.