CF400C.Inna and Huge Candy Matrix

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 11 to nn from top to bottom and the columns — from 11 to mm , from left to right. We'll represent the cell on the intersection of the ii -th row and jj -th column as (i,j)(i,j) . Just as is expected, some cells of the giant candy matrix contain candies. Overall the matrix has pp candies: the kk -th candy is at cell (xk,yk)(x_{k},y_{k}) .

The time moved closer to dinner and Inna was already going to eat pp of her favourite sweets from the matrix, when suddenly Sereja (for the reason he didn't share with anyone) rotated the matrix xx times clockwise by 90 degrees. Then he performed the horizontal rotate of the matrix yy times. And then he rotated the matrix zz times counterclockwise by 90 degrees. The figure below shows how the rotates of the matrix looks like.

Inna got really upset, but Duma suddenly understood two things: the candies didn't get damaged and he remembered which cells contained Inna's favourite sweets before Sereja's strange actions. Help guys to find the new coordinates in the candy matrix after the transformation Sereja made!

输入格式

The first line of the input contains fix integers nn , mm , xx , yy , zz , pp (1<=n,m<=109; 0<=x,y,z<=109; 1<=p<=105)(1<=n,m<=10^{9}; 0<=x,y,z<=10^{9}; 1<=p<=10^{5}) .

Each of the following pp lines contains two integers xkx_{k} , yky_{k} (1<=xk<=n; 1<=yk<=m)(1<=x_{k}<=n; 1<=y_{k}<=m) — the initial coordinates of the kk -th candy. Two candies can lie on the same cell.

输出格式

For each of the pp candies, print on a single line its space-separated new coordinates.

输入输出样例

  • 输入#1

    3 3 3 1 1 9
    1 1
    1 2
    1 3
    2 1
    2 2
    2 3
    3 1
    3 2
    3 3
    

    输出#1

    1 3
    1 2
    1 1
    2 3
    2 2
    2 1
    3 3
    3 2
    3 1
    

说明/提示

Just for clarity. Horizontal rotating is like a mirroring of the matrix. For matrix:

<br></br>QWER REWQ <br></br>ASDF -> FDSA<br></br>ZXCV VCXZ<br></br>

首页