Final Coordinates
题号:NC273389
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Given an n \times n grid, where the horizontal coordinate ranges from 1 to n, and the vertical coordinate ranges from 1 to n.

For each grid cell (x, y), its energy at the t-th second is defined as f(x, y, t) = (x + y + t). For example, for the grid cell at (1, 1), its energy at the 0-th second is 2, at the 1-th second is 3, and so on.

Initially (at the 0-th second), the character is located in the grid cell with coordinates (sx, sy). Initially, the character has a horizontal velocity of dx and a vertical velocity of dy.

Your character possesses a magical acceleration item. When you are at point (x, y), your velocity will be boosted, and both your horizontal and vertical velocities will increase by the energy value of the grid cell you are in. For example, if your current horizontal velocity is 3, vertical velocity is 4, and the grid cell has an energy of 6, then your velocity will change to horizontal velocity 9 and vertical velocity 10.

After gaining the boost, your character will start moving based on your velocity. Let the new velocities be denoted by new dx and dy. Then, for each second passed, the character moves to the position ((x+dx-1) \% n + 1, (y+dy-1) \% n + 1).

Your task is to determine the coordinates where the character will be after t seconds.

输入描述:

One line containing six integers separated by spaces, representing n, sx, sy, dx, dy, t.

1 \le n\le 10^9, 1\le sx,sy\le n, 0\le dx,dy\le n, 1\le t \le 10^{18}

输出描述:

One line containing two positive integers separated by a space, representing the final horizontal and vertical coordinates of the character.
示例1

输入

复制
5 1 2 0 1 2

输出

复制
3 1

说明

from 0 second to 2 second: (1, 2) -> (4, 1) -> (3, 1).