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 JavaScript (judge verdict: Wrong Answer)

function generateTrianglesFromInput(input) {
  var maxLines = 1000;
  var offset = 1;

  var lines = getInputAsLines(input, "\n");
  var vertices = lines.map(processLineToVertices);
  var limit = (vertices.length < maxLines) ? vertices.length : maxLines;

  for(var i = offset; i <= limit; i++) {
    var vertexLine = vertices[i];
    if(vertexLine && vertexLine.length === 3) {
      var tri = new Triangle({
        constraints: {
          min: 1,
          max: 1000
        },
        vertices: {
          a: vertexLine[0],
          b: vertexLine[1],
          c: vertexLine[2]
        }
      });

      var isRightAngleTriangle = tri.isRightAngleTriangle();
      var logValue = (isRightAngleTriangle) ? 'YES' : 'NO';
      console.log(logValue);
    }
  }
}

function getInputAsLines(input, delimeter) {
  return input.split(delimeter);
}

function processLineToVertices(line) {
  var vertices = line.split(' ');
  return vertices;
}


//Triangle
function Triangle(options) {

  this.constraints = {};
  this.vertices = {};

  //Set up triangle constraints.
  this.constraints.min = options.constraints.min || 1;
  this.constraints.max = options.constraints.max || 1000;

  //Set up triangle vertices
  this.vertices.a = (this.vertexIsWithinConstraints(options.vertices.a)) ? options.vertices.a : null;
  this.vertices.b = (this.vertexIsWithinConstraints(options.vertices.b)) ? options.vertices.b : null;
  this.vertices.c = (this.vertexIsWithinConstraints(options.vertices.c)) ? options.vertices.c : null;

}

Triangle.prototype.vertexIsWithinConstraints = function(vertex) {
  return (vertex >= this.constraints.min && vertex <= this.constraints.max);
}

Triangle.prototype.isRightAngleTriangle = function() {
  var value = false;
  if(this.vertices.a && this.vertices.b && this.vertices.c) {
    var vertexArray = [];
    vertexArray.push(this.vertices.a);
    vertexArray.push(this.vertices.b);
    vertexArray.push(this.vertices.c);

    vertexArray.sort();

    var squares = vertexArray.map(function (vertex) { return Math.pow(vertex, 2)});
    value = (squares[2] === (squares[0] + squares[1]));
  }

  return value;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
generateTrianglesFromInput(input);