#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;
	}
}