Binary Number

Interview

Time limit1sMemory limit128 MB

Summary
For each given integer, output the positions of all bits set to 1 in its binary representation, from least to most significant.
Level

Easy2 of 10

Topics
Bit manipulation, Implementation
Solved
No attempts yet

Problem

You are given a positive integer nn. Write a program that finds the positions of all bits equal to 11 in the binary representation of nn. Bit positions are numbered starting from the least significant bit (LSB), which is position 00, and increase by 11 toward the most significant bit.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains a single integer nn.

  • 1≤T≤101 \le T \le 10
  • 1≤n≤1061 \le n \le 10^6

Output

For each test case, print on one line the positions of the bits equal to 11, in increasing order of position, separated by single spaces.

Examples6

  1. Example 1

    Input
    1
    13
    
    Expected output
    0 2 3
    
  2. Example 2

    Input
    1
    1
    
    Expected output
    0
    
  3. Example 3

    Input
    1
    2
    
    Expected output
    1
    
  4. Example 4

    Input
    1
    1024
    
    Expected output
    10
    
  5. Example 5

    Input
    1
    1023
    
    Expected output
    0 1 2 3 4 5 6 7 8 9
    
  6. Example 6

    Input
    3
    7
    8
    1000000
    
    Expected output
    0 1 2
    3
    6 9 14 16 17 18 19