#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int a[N];
int C[N];
int F[4][N];
int f(int l, int r)
{
    for (int i = l; i <= r; i++) C[i]++;
    return a[r] ^ a[l - 1];
}
int g(int l, int r)
{
    int ret = 0;
    for (int i = l; i <= r; i++)
        for (int j = i; j <= r; j++)
            ret ^= f(i, j);
    return ret;
}
int w_brute(int l, int r)
{
    int ret = 0;
    for (int i = l; i <= r; i++)
        for (int j = i; j <= r; j++)
            ret ^= g(i, j);
    return ret;
}
int w(int l, int r)
{
    int len = (r - l + 1) & 3;
    int offset, offset1, offset2;
    switch (len)
    {
    case 0:
        return 0;
    case 1:
        offset = (l - 1) & 3;
        return F[offset][r] ^ F[offset][l - 1];
    case 2:
        offset1 = (l - 1) & 3;
        offset2 = (l)&3;
        return F[offset1][r] ^ F[offset1][l - 1] ^ F[offset2][r] ^ F[offset2][l - 1];
    case 3:
        offset = (l)&3;
        return F[offset][r] ^ F[offset][l - 1];
    }
}
int main()
{
    /*for (int i = 1; i <= 15; i++)
    {
        memset(C, 0, sizeof C);
        w(1, i);
        for (int j = 1; j <= i; j++)
            printf("%d ", C[j] & 1);
        putchar('\n');
    }
    return 0;*/
    int T, n, Q;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d", &n);
        for (int i = 1; i <= n; i++)
            scanf("%d", a + i);
        for (int i = 0; i < 4; i++)
        {
            int *ff = F[i];
            for (int j = 1 + i; j <= n; j += 4)
                ff[j] = a[j];
            for (int j = 1; j <= n; j++) ff[j] ^= ff[j - 1];
        }
        for (int j = 1; j <= n; j++) a[j] ^= a[j - 1];
        for (int l = 1; l <= n; l++)
            for (int r = l; r <= n; r++)
                printf("%d %d %d %d\n", l, r, w(l, r), w_brute(l, r));
        continue;
        scanf("%d", &Q);
        while (Q--)
        {
            int l, r;
            scanf("%d%d", &l, &r);
            printf("%d %d\n", w(l, r), w_brute(l, r));
        }
    }
    return 0;
}
