# 26. 最多几个直角三角形

26

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

function dfs(arr, used, index, count) {
    let ans = count;
    for(let i=index; i<arr.length; i++) {
        if(used[i]) {
            continue;
        }
        for(let j=i+1; j<arr.length; j++) {
            if(used[j]) {
                continue;
            }
            for(let k=j+1; k<arr.length; k++) {
                if(used[k]) {
                    continue;
                }
                if (arr[i] ** 2 + arr[j] ** 2 === arr[k] ** 2) {
                    used[i] = true;
                    used[j] = true;
                    used[k] = true;
                    ans = Math.max(ans, dfs(arr, used, i+1, count+1));
                    used[i] = false;
                    used[j] = false;
                    used[k] = false;
                }
            }
        }
    }
    return ans;
}

const lines = [];
rl.on('line', (test_cases) => {
    test_cases = parseInt(test_cases);
    const input_data = [];
    let read_count = 0;
    rl.on('line', (line)=>{
        input_data.push(line.split(' ').slice(1).map(Number));
        read_count++;
        if (read_count === test_cases) {
            for(const testCase of input_data) {
                testCase.sort((a, b) => a-b);
                console.log(dfs(testCase, Array(testCase.length).fill(false), 0, 0))
            }
        }
    })
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51