Given a non-negative number **n** and two values **l** and **r**. The problem is to count the number of unset bits in the range **l** to **r** in the binary representation of **n**, i.e. to count unset bits from the rightmost **lth** bit to the rightmost **rth** bit.

**Examples:**

```
Input : n = 42, l = 2, r = 5
Output : 2
```**(42)**_{10} = (1**0101**0)_{2}
There are '2' unset bits in the range 2 to 5.
Input : n = 80, l = 1, r = 4
Output : 4

**Input:** The first line of the input contains a single integer **T**, denoting the number of test cases. Then**T** test cases follow. Each test-case has one line of the input, the line contains three integers **n**,** l** and **r**.

**Output:**

Print the required output.

**Constraints:**

1 <= T <= 100

1 <= n,l,r <= 100000

**Examples:
Input:**

2

64 4 7

80 1 4

3

4

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.

saiujwal13083 | 347 |

isiddhisingh | 252 |

Abhishek_Jadhav | 243 |

_uncle_sam_ | 221 |

c_ocoooo | 217 |

saiujwal13083 | 610 |

SumitSingh27 | 466 |

c_ocoooo | 456 |

rathiarpit29 | 379 |

NaveenKumarNakka | 370 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4931 |

Quandray | 4598 |

Login to report an issue on this page.