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.

vamsikrishna55 | 162 |

Vagesh Verma | 154 |

UrGuru | 133 |

chaolinyu | 98 |

Akhil varma | 97 |

abducodes | 650 |

harshtyagi36 | 304 |

highway_to_hell | 252 |

Akhil varma | 250 |

arpit_anshuman | 250 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.