This page is still under construction.

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

Ari's Clever Portal Trip

Time limit1sMemory limit512 MB

Summary
Simulate Ari's zigzag walk from row 1 to the portal at (N, M) and report whether the path passes through the minion cell (Sr, Sc).
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

To hunt the boss monster, Ari has to take the portal in the wilderness. However, the wilderness also holds one minion monster, the right arm of the boss monster, which tries to stop Ari from reaching the portal. The wilderness is an N×MN \times M grid with NN rows and MM columns. The top left cell is (1,1)(1, 1) and the bottom right cell is (N,M)(N, M). Ari starts at (1,Ac)(1, Ac), the minion monster is at (Sr,Sc)(Sr, Sc), and the portal is at (N,M)(N, M). The minion monster is never located at (N,M)(N, M).

The minion monster cannot move from its starting cell, so it cannot block Ari directly. Instead, it casts a spell on Ari's movement:

  • Ari moves either left or right.
  • If Ari is moving left, Ari must go to the left end of the row. If Ari is moving right, Ari must go to the right end of the row. When Ari reaches the end of a row, Ari moves down one row.
  • When Ari moves down, the direction becomes the opposite of the direction in the row above.

For example, when the grid has 5 rows and 6 columns and Ari starts at (1,3)(1, 3), Ari's paths for each direction are shown below.

Ari moving leftAri moving right

Under these restrictions, Ari may meet the minion monster, or may go straight to the portal without meeting it. Before Ari leaves, check whether Ari meets the minion monster.

Input

The first line contains two integers NN and MM, the size of the wilderness. (2≤N,M≤1002 \le N, M \le 100)

The second line contains an integer AcAc (1≤Ac≤M1 \le Ac \le M), the column where Ari starts, and Ari's direction DD. DD is either 0 or 1. If DD is 0, Ari moves left. If DD is 1, Ari moves right.

The third line contains two integers SrSr (2≤Sr≤N2 \le Sr \le N) and ScSc (1≤Sc≤M1 \le Sc \le M), the position of the minion monster.

Output

If Ari can reach the portal without meeting the minion monster, print "YES!" on the first line. If Ari meets the minion monster, print "NO...".

Examples2

  1. Example 1

    Input
    5 6
    3 0
    5 5
    
    Expected output
    YES!
    
  2. Example 2

    Input
    5 6
    3 1
    5 5
    
    Expected output
    NO...