This page is still under construction.

Parts of this page are still being built. What you see may change.

Triangle

Time limit2sMemory limit256 MB

Summary
Decide whether two given integer-sided triangles are congruent right triangles that can form a rectangle split along its diagonal.
Level

Medium4 of 10

Topics
Geometry, Math, Sorting
Solved
No attempts yet

Problem

You cut one rectangular sheet of paper into two pieces with a single straight line segment. You may then rotate and flip each piece freely.

Given the three side lengths of two triangles, decide whether the two pieces can be exactly those triangles. In other words, decide whether some rectangle exists such that one straight cut leaves two pieces matching the two given triangles. The side lengths of the rectangle do not have to be integers.

Input

The input has two lines. The first line contains the three side lengths of the first triangle, separated by spaces. The second line contains the three side lengths of the second triangle in the same format.

Every side length is a positive integer of at most 100100, and the three numbers on each line always form a triangle.

Output

Print YES on the first line if such a rectangle exists, and NO otherwise.

Examples3

  1. Example 1

    Input
    3 4 5
    4 3 5
    
    Expected output
    YES
    
  2. Example 2

    Input
    3 4 6
    4 6 3
    
    Expected output
    NO
    
  3. Example 3

    Input
    39 52 65
    25 60 65
    
    Expected output
    NO