import java.io.*;
import java.util.*;

public class xor_as implements Runnable {

    public void solve() throws IOException {
        Scanner in = new Scanner(new File("xor.in"));
        PrintWriter out = new PrintWriter(new File("xor.out"));

        int n = in.nextInt();
        long[] a = new long[n];
        int[] b = new int[n];
        int m = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextLong();
            long x = a[i];
            int z = 0;
            while (x > 0) {
                if (x % 2 != 0) {
                    b[i]++;
                }
                x /= 2;
                z++;
            }
            if (z > m) {
                m = z;
            }
        }

        boolean[][] d = new boolean[n + 1][m + 1];
        int[][] zo = new int[n + 1][m + 1];
        int[][] oo = new int[n + 1][m + 1];
        d[0][0] = true;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= m; j++) {
                if (d[i][j]) {
                    for (int k = Math.max(0, b[i] - (m - j)); k <= b[i] && k <= j; k++) {
                        int l = (j - k) + (b[i] - k);
                        d[i + 1][l] = true;
                        oo[i + 1][l] = k;
                    }
                }
            }
        }

        if (d[n][0]) {
            long z = 0;
            long[] c = new long[n];
            int p = 0;
            for (int k = n; k > 0; k--) {
                int loo = oo[k][p];
                int loz = (b[k - 1] - oo[k][p]);
                int np = p + loo - loz;
                for (int i = 0; i < m; i++) {
                    if ((z & (1L << i)) != 0) {
                        if (loz > 0) {
                            c[k - 1] |= (1L << i);
                            loz--;
                        }
                    } else {
                        if (loo > 0) {
                            c[k - 1] |= (1L << i);
                            loo--;
                        }
                    }
                }
                z ^= c[k - 1];
                p = np;
            }
            for (int i = 0; i < n; i++) {
                out.print(c[i] + " ");
            }
            out.println();
        } else {
            out.println("impossible");
        }

        in.close();
        out.close();
    }

    public void run() {
        try {
            solve();
        } catch (IOException e) {
            System.exit(64);
        }
    }

    public static void main(String[] arg) throws IOException {
        new Thread(new xor_as()).start();
    }
}
