A ball bounces inside an R by C grid of cells (rows 0..R-1, columns 0..C-1). It starts on a given cell with a diagonal velocity (dr, dc), where each of dr and dc is either -1 or +1. Each step it tries to move by its current velocity. Before committing the move, if moving would carry the row out of [0, R-1] the vertical component dr is reversed, and independently if moving would carry the column out of [0, C-1] the horizontal component dc is reversed; then the ball moves by the (possibly reversed) velocity. Report the cell after exactly T steps.
Input format
Line 1: two integers R and C.
Line 2: four integers r0 c0 dr dc (the start cell and the velocity, each of dr, dc in {-1, 1}).
Line 3: an integer T, the number of steps.
Output format
A single line r c: the ball's cell after T steps.
Constraints
- 2 <= R, C <= 1000
- 0 <= r0 <= R-1, 0 <= c0 <= C-1
- dr, dc in {-1, 1}
- 0 <= T <= 1000000