Under construction

Still being built. Things may change

Target

Time limit1sMemory limit1024 MB

Summary
Given a window grid, a target grid, and a wind offset, find the smallest TX+TY over target cells the arrow can land on, or report NEPATAIKYS if none exists.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

A rectangular target stands behind a rectangular shooting window. Both the window and the target are divided into 1 × 1 cells.

A line through the bottom-left corners of the two rectangles is perpendicular to their planes, and the bottom edges of both rectangles are parallel.

The bottom-left cell of both rectangles has coordinates (0, 0).

Adam can shoot from any cell (Xp, Yp) of the window. However, the wind pushes the arrow sideways by (X, Y) cells, so an arrow shot from (Xp, Yp) lands on (Xp + X, Yp + Y).

Adam must hit one cell of the target. If the arrow lands on target cell (TX, TY), the penalty is TX + TY. The wind may keep the arrow from hitting the target at all.

Determine whether Adam can hit the target at all, and if so, the minimum penalty he can receive.

Input

The first line contains the window width M and height N. The second line contains the target width A and height B. The third line contains the wind offsets X and Y. All numbers are integers.

Output

Output the minimum possible penalty as a single integer. If the wind makes it impossible to hit the target, output NEPATAIKYS.

Constraints

1 ≤ N, M, A, B ≤ 1000 -2000 ≤ X, Y ≤ 2000

Examples2

  1. Example 1

    Input
    1 1
    3 4
    2 2
    
    Expected output
    4
    
  2. Example 2

    Input
    1 1
    3 4
    2 1
    
    Expected output
    3