// checker 由 AI 从下面的 testlib 格式 checker 转换而来。

/*
#include <bits/stdc++.h>
#include "testlib.h"
using namespace std;
int main(int argc, char** argv)
{
	registerTestlibCmd(argc, argv);
	int T = inf.readInt();
	for (int t = 1; t <= T; t++)
	{
		setTestCase(t);
		long long n = inf.readLong();
		long long jx = ans.readLong(-1, n), jy = ans.readLong(-1, n);
		__int128 px = ouf.readLong(-1, n), py = ouf.readLong(-1, n);
		if (px == -1 && py != -1) quitf(_wa, "Invalid output!");
		if (px != -1 && py == -1) quitf(_wa, "Invalid output!");
		if (px == -1 && jx != -1 && jy != -1) quitf(_wa, "Construction failed!");
		if (px != -1 && px * px - py * py != n) quitf(_wa, "Wrong construction!");
		if (px != -1 && px * px - py * py == n && jx == -1) quitf(_fail, "System error!");
	}
	quitf(_ok, "Accepted!");
	return 0;
}
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    FILE* input_file = fopen("input", "r");
    FILE* user_file = fopen("user_out", "r");
    FILE* ans_file = fopen("answer", "r");

    if (!user_file) {
        fprintf(stderr, "Invalid output!\n");
        printf("0\n");
        fclose(user_file);
        fclose(ans_file);
        return 0;
    }

    if (!ans_file) {
        fprintf(stderr, "Invalid answer!\n");
        return 1;
    }

    int T;
    if (fscanf(input_file, "%d", &T) != 1) {
        fprintf(stderr, "Invalid input!\n");
        fclose(user_file);
        fclose(ans_file);
        return 1;
    }

    for (int t = 1; t <= T; t++) {
        long long n;
        if (fscanf(input_file, "%lld", &n) != 1) {
            fprintf(stderr, "Invalid input! (test case %d)\n", t);
            fclose(user_file);
            fclose(ans_file);
            return 1;
        }

        long long jx, jy;
        if (fscanf(ans_file, "%lld %lld", &jx, &jy) != 2) {
            fprintf(stderr, "Invalid answer! (test case %d)\n", t);
            fclose(user_file);
            fclose(ans_file);
            return 1;
        }

        // 验证答案范围
        if (jx < -1 || jx > n || jy < -1 || jy > n) {
            fprintf(stderr, "Invalid answer! (test case %d)\n", t);
            fclose(user_file);
            fclose(ans_file);
            return 1;
        }

        long long px, py;
        if (fscanf(user_file, "%lld %lld", &px, &py) != 2) {
            fprintf(stderr, "Invalid output! (test case %d)\n", t);
            printf("0\n");
            fclose(user_file);
            fclose(ans_file);
            return 0;
        }

        // 验证用户输出范围
        if (px < -1 || px > n || py < -1 || py > n) {
            fprintf(stderr, "Invalid output! (test case %d)\n", t);
            printf("0\n");
            fclose(user_file);
            fclose(ans_file);
            return 0;
        }

        // 检查输出合法性
        if (px == -1 && py != -1) {
            fprintf(stderr, "Invalid output! (test case %d)\n", t);
            printf("0\n");
            fclose(user_file);
            fclose(ans_file);
            return 0;
        }

        // 检查构造失败的情况
        if (px == -1 && jx != -1 && jy != -1) {
            fprintf(stderr, "Construction failed! (test case %d)\n", t);
            printf("0\n");
            fclose(user_file);
            fclose(ans_file);
            return 0;
        }

        // 检查构造是否正确
        if (px != -1 && px * px - py * py != n) {
            fprintf(stderr, "Wrong construction! (test case %d)\n", t);
            printf("0\n");
            fclose(user_file);
            fclose(ans_file);
            return 0;
        }

        // 系统错误检查（如果用户构造正确但答案说无解）
        if (px != -1 && px * px - py * py == n && jx == -1) {
            fprintf(stderr, "System error! (test case %d)\n", t);
            fclose(user_file);
            fclose(ans_file);
            return 1;
        }
    }

    fprintf(stderr, "Accepted! (%d test case%s)\n", T, ((T == 1) ? "" : "s"));
    printf("100\n");  // 满分

    fclose(user_file);
    fclose(ans_file);
    return 0;
}
