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.

Akkki111 | 38 |

SaltBaeSama | 34 |

ambercyrus | 33 |

LegendFire | 32 |

chocozz | 32 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1219 |

mazumderrohit8 | 1095 |

SumitSingh27 | 1090 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4566 |

Quandray | 4444 |

Login to report an issue on this page.