#include<iostream>
using namespace std;
main(){
int test_case;
cin >> test_case;
while (test_case--) {
int X;
cin >> X;
int dem =0;
for (int i = 0; i*i <= X; i++) {
int a = i*i;
int b = X - a;
if (b >= 0) {
int b1 = 0;
while (b1 * b1 <= b){
if (b1*b1 == b) dem++;
b1++;
}
}
}
cout << dem << endl;
}
}
I2luY2x1ZGU8aW9zdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKbWFpbigpewoJaW50IHRlc3RfY2FzZTsKCWNpbiA+PiB0ZXN0X2Nhc2U7Cgl3aGlsZSAodGVzdF9jYXNlLS0pIHsKCQlpbnQgWDsKCQljaW4gPj4gWDsKCQoJCWludCBkZW0gPTA7CgkJZm9yIChpbnQgaSA9IDA7IGkqaSA8PSBYOyBpKyspIHsKCQkJaW50IGEgPSBpKmk7CgkJCWludCBiID0gWCAtIGE7CgkJCWlmIChiID49IDApIHsKCQkJCWludCBiMSA9IDA7CgkJCQl3aGlsZSAoYjEgKiBiMSA8PSBiKXsKCQkJCQlpZiAoYjEqYjEgPT0gYikgZGVtKys7CgkJCQkJYjErKzsKCQkJCX0JCgkJCX0KCQl9CgkJY291dCA8PCBkZW0gPDwgZW5kbDsKCX0KfQ==