Under construction

Still being built. Things may change

Four Square

Time limit4sMemory limit2048 MB

Summary
Given four rectangular panes, decide whether they can be rotated and placed without overlap to tile a square.
Level

Easy3 of 10

Topics
Implementation, Brute force
Solved
No attempts yet

Problem

Inspired by a Piet Mondrian painting, you want to make a four-pane window out of four colored rectangles of glass. You are given the sizes of the four panes of glass. Can you arrange them into a square? You may rotate the panes. The panes should cover the entire square without overlap.

Input

The input consists of exactly four lines. Each of the four lines contains two integers ww and hh (1≤w,h≤1 0001 \le w,h \le 1\,000), representing the width and height of one of the four rectangular panes of glass.

Output

Output a single integer, which is 11 if the four panes can be arranged to form a square, and 00 otherwise.

Examples2

  1. Example 1

    Input
    1 1
    1 1
    1 1
    1 1
    
    Expected output
    1
    
  2. Example 2

    Input
    3 1
    3 3
    2 2
    3 3
    
    Expected output
    0