#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1)
int N;
double get_angle(int sz) {
int dot = (-sz * 2) + (sz - 1);
int len = (sz) + (sz) * (sz);
return acos(dot *1.0 / len*1.0);
}
void solve(vector<vector<double> >& pts, int cur) {
if (cur == N+2) return;
double theta = get_angle(cur - 1) - PI / 2;
for (int i = 0; i < pts.size(); i++) {
for (int k = 0; k < pts[i].size(); k++) {
pts[i][k] *= cos(theta);
}
pts[i].push_back(-sin(theta));
}
vector<double> new_pt;
for (int i = 2; i < cur; i++) new_pt.push_back(0);
new_pt.push_back(1);
pts.push_back(new_pt);
solve(pts, cur + 1);
}
int main() {
cout << fixed << setprecision(9);
int T; cin >> T;
while (T) {
cin >> N;
if (N == 1) {
cout << 1 << "\n" << -1 << "\n";
} else {
vector<vector<double> > pts;
vector<double> p1, p2;
p1.push_back(1);
p2.push_back(-1);
pts.push_back(p1); pts.push_back(p2);
solve(pts, 3);
for (int i = 0; i < pts.size(); i++) {
for (int k = 0; k < pts[i].size(); k++) {
cout << pts[i][k] << " ";
} cout << "\n";
}
}
cout << "\n";
T--;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIFBJIGFjb3MoLTEpCmludCBOOwoKZG91YmxlIGdldF9hbmdsZShpbnQgc3opIHsKICAgIGludCBkb3QgPSAoLXN6ICogMikgKyAoc3ogLSAxKTsKICAgIGludCBsZW4gPSAoc3opICsgKHN6KSAqIChzeik7CiAgICByZXR1cm4gYWNvcyhkb3QgKjEuMCAvIGxlbioxLjApOwp9Cgp2b2lkIHNvbHZlKHZlY3Rvcjx2ZWN0b3I8ZG91YmxlPiA+JiBwdHMsIGludCBjdXIpIHsKICAgIGlmIChjdXIgPT0gTisyKSByZXR1cm47CiAgICBkb3VibGUgdGhldGEgPSBnZXRfYW5nbGUoY3VyIC0gMSkgLSBQSSAvIDI7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IHB0cy5zaXplKCk7IGkrKykgewogICAgICAgIGZvciAoaW50IGsgPSAwOyBrIDwgcHRzW2ldLnNpemUoKTsgaysrKSB7CiAgICAgICAgICAgIHB0c1tpXVtrXSAqPSBjb3ModGhldGEpOwogICAgICAgIH0KICAgICAgICBwdHNbaV0ucHVzaF9iYWNrKC1zaW4odGhldGEpKTsKICAgIH0KICAgIHZlY3Rvcjxkb3VibGU+IG5ld19wdDsKICAgIGZvciAoaW50IGkgPSAyOyBpIDwgY3VyOyBpKyspIG5ld19wdC5wdXNoX2JhY2soMCk7CiAgICBuZXdfcHQucHVzaF9iYWNrKDEpOwogICAgcHRzLnB1c2hfYmFjayhuZXdfcHQpOwoKICAgIHNvbHZlKHB0cywgY3VyICsgMSk7Cn0KCmludCBtYWluKCkgewoKICAgIGNvdXQgPDwgZml4ZWQgPDwgc2V0cHJlY2lzaW9uKDkpOwoKICAgIGludCBUOyBjaW4gPj4gVDsKICAgIHdoaWxlIChUKSB7CiAgICAgICAgY2luID4+IE47CiAgICAgICAgaWYgKE4gPT0gMSkgewogICAgICAgICAgICBjb3V0IDw8IDEgPDwgIlxuIiA8PCAtMSA8PCAiXG4iOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHZlY3Rvcjx2ZWN0b3I8ZG91YmxlPiA+IHB0czsKICAgICAgICAgICAgdmVjdG9yPGRvdWJsZT4gcDEsIHAyOwogICAgICAgICAgICBwMS5wdXNoX2JhY2soMSk7CiAgICAgICAgICAgIHAyLnB1c2hfYmFjaygtMSk7CiAgICAgICAgICAgIHB0cy5wdXNoX2JhY2socDEpOyBwdHMucHVzaF9iYWNrKHAyKTsKICAgICAgICAgICAgc29sdmUocHRzLCAzKTsKCiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcHRzLnNpemUoKTsgaSsrKSB7CiAgICAgICAgICAgICAgICBmb3IgKGludCBrID0gMDsgayA8IHB0c1tpXS5zaXplKCk7IGsrKykgewogICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgcHRzW2ldW2tdIDw8ICIgIjsKICAgICAgICAgICAgICAgIH0gY291dCA8PCAiXG4iOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvdXQgPDwgIlxuIjsKICAgICAgICBULS07CiAgICB9CgogICAgcmV0dXJuIDA7Cn0=