#include <bits/stdc++.h>
const int INF = 1e9;
const int N = 312312;
const double PI = 3.1415926535897932384626433832795;
using namespace std;
pair<int, int> a[N];
int n, m, z, x, y, kol;
void cl() {
  for (int c = 1; c <= kol; c++) {
    int curx = a[c].second;
    int cury = n - a[c].first + 1;
    a[c].first = curx;
    a[c].second = cury;
  }
  swap(n, m);
}
void anticl() {
  for (int c = 1; c <= kol; c++) {
    int curx = m - a[c].second + 1;
    int cury = a[c].first;
    a[c].first = curx;
    a[c].second = cury;
  }
  swap(n, m);
}
void rev() {
  for (int c = 1; c <= kol; c++) {
    a[c].second = m - a[c].second + 1;
  }
}
int main() {
  ios_base ::sync_with_stdio();
  int c;
  cin >> n >> m >> x >> y >> z >> kol;
  for (c = 1; c <= kol; c++) {
    scanf("%d %d", &a[c].first, &a[c].second);
  }
  x %= 4;
  y %= 2;
  z %= 4;
  while (x--) cl();
  while (y--) rev();
  while (z--) anticl();
  for (c = 1; c <= kol; c++) {
    printf("%d %d\n", a[c].first, a[c].second);
  }
  return 0;
}
