#include <bits/stdc++.h>
using namespace std;
int a[500000], b[500000], ni, nj, i, j;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m, x, y, z, p;
  cin >> n >> m >> x >> y >> z >> p;
  for (long long i = 1; i <= p; i++) cin >> a[i] >> b[i];
  for (long long j = 1; j <= x % 4; j++) {
    for (long long i = 1; i <= p; i++) {
      ni = b[i];
      nj = n - a[i] + 1;
      a[i] = ni;
      b[i] = nj;
    }
    swap(n, m);
  }
  for (long long j = 1; j <= y % 2; j++) {
    for (long long i = 1; i <= p; i++) {
      nj = m - b[i] + 1;
      b[i] = nj;
    }
  }
  for (long long j = 1; j <= z % 4; j++) {
    for (long long i = 1; i <= p; i++) {
      nj = a[i];
      ni = m - b[i] + 1;
      a[i] = ni;
      b[i] = nj;
    }
    swap(n, m);
  }
  cout << endl;
  for (long long i = 1; i <= p; i++) cout << a[i] << " " << b[i] << "\n";
  return 0;
}
