#include <stdio.h>

int main() {
    int num_cases;
    scanf("%d", &num_cases);
    for (int i = 0; i < num_cases; i++) {
        int counts[20];
        for (int j = 0; j < 20; j++) {
            scanf("%d", &counts[j]);
        }
        for (int j = 19; j > 0; j--) {
            counts[j - 1] += counts[j] / 2;
            counts[j] %= 2;
        }
        printf("%d", counts[0]);
        for (int j = 1; j < 20; j++) {
            printf(" %d", counts[j]);
        }
        printf("\n");
    }
    return 0;
}