Given a number **N**, print all the numbers which are a bitwise subset of the binary representation of N. Bitwise subset of a number **N** will be the numbers **i** in the range **0<=i<=N** which satisfy the below condition:

**N & i == i**

**Input:**

The first line of input contains an integer **T ** denoting the number of test cases. For each test case, there is an integer **N **denoting the number.

**Output:**

For each test case, the output is the space separated integers that satisfy the above condition.

**Constraints:**

1<=T<=100

1<=N<=10000

**Example:
Input**

2

5

9

5 4 1 0

9 8 1 0

**Explanation:
For 1st test case:
**0 & 5 = 0

1 & 5 = 1

2 & 5 = 0

3 & 5 = 1

4 & 5 = 4

5 & 5 = 5

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.

cs_abhi | 102 |

PiyushPandey4 | 100 |

codefundo | 95 |

kya_bolti_public | 93 |

masterishaan19 | 74 |

PiyushPandey4 | 916 |

john_wick | 765 |

ASWATHAMA | 565 |

UsfShilpa | 556 |

akhyasharma01 | 547 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.