Problem:
Is it a Right Triangle?

Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.

Input

Input consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.

Constraints

1 ≤ length of the side ≤ 1,000

N ≤ 1,000

Output

For each data set, print "YES" or "NO".

Sample Input

3
4 3 5
4 3 6
8 8 8

Output for the Sample Input

YES
NO
NO

Solution in JAVA (judge verdict: Wrong Answer)

import java.io.*;
import java.util.*;

class Main{
	private static ArrayList<String> tri_check(ArrayList<Integer> a){
		ArrayList<String> b = new ArrayList<String>();
		
		for(int i = 0;i<a.size()/3;i++){
			int x2,y2,z2;
			if(i == 0){
				x2 = a.get(0)*a.get(0);
				y2 = a.get(1)*a.get(1);
				z2 = a.get(2)*a.get(2);
			}
			x2 = a.get(i*3)*a.get(i*3);
			y2 = a.get(i*3+1)*a.get(i*3+1);
			z2 = a.get(i*3+2)*a.get(i*3+2);
			
			if((x2+ y2) == z2 || (x2 + z2) == y2 || (y2 + z2) == x2)b.add("YES");  
			b.add("NO");
			}
		return b;
	}
	private static void print_tri(ArrayList<String> a){
		for(int i = 0;i<a.size();i++){
			System.out.println(a.get(i));
		}
	}
		public static void main(String args[]) throws IOException{
			ArrayList<Integer> tri = new ArrayList<Integer>();
			Scanner scan = new Scanner(System.in);
			scan.useDelimiter("\\r\\n");

			while(scan.hasNext()){
				try{
					String str1 = scan.next();
					String[] str1Ary = str1.split(" ");
					
					System.out.println(str1Ary.length);
					if(str1Ary.length != 3) continue;
					
					for(int i = 0;i < 3;i++){
						tri.add(Integer.parseInt(str1Ary[i]));
					}
				}
				catch(NumberFormatException e){
					break;
				}
				String str1 = scan.next();
					String[] str1Ary = str1.split(" ");
					
					System.out.println(str1Ary.length);
					if(str1Ary.length != 3) continue;
					
					for(int i = 0;i < 3;i++){
						tri.add(Integer.parseInt(str1Ary[i]));
					}
			}
			ArrayList<String> res = new ArrayList<String>();
			res = tri_check(tri);
			print_tri(res);
	}
}