#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T MAX(T a, T b) {     if (a > b) return a;     return b;   }   template <class T>   inline T MIN(T a, T b) {     if (a < b) return a;     return b;   }   template <class T>   inline T ABS(T x) {     if (x < 0) return -x;     return x;   }   inline void OPEN(const string &s) {     freopen((s +  .in ).c_str(),  r , stdin);     freopen((s +  .out ).c_str(),  w , stdout);   }   const static int inf = 1000000000;   int n, m, x, y, z, p;   int a, b;   vector<pair<int, int> > cek;   void rotate90(int &a, int &b, int &r, int &c) {     int tempa = a;     int tempb = b;     a = tempb;     b = r - tempa + 1;     swap(r, c);   }   void flipH(int &a, int &b, int &r, int &c) { b = c - b + 1; }   void rotate(int &a, int &b, int &r, int &c) {     int tempa = a;     int tempb = b;     a = c - tempb + 1;     b = tempa;     swap(r, c);   }   int main() {     scanf( %d%d%d%d%d%d , &n, &m, &x, &y, &z, &p);     for (int(i) = (0); (i) < (p); ++(i)) {       scanf( %d%d , &a, &b);       cek.push_back(make_pair(a, b));     }     x %= 4;     z %= 4;     y %= 2;     for (int(i) = (0); (i) < (cek.size()); ++(i)) {       a = cek[i].first;       b = cek[i].second;       int r = n, c = m;       for (int(j) = (0); (j) < (x); ++(j)) rotate90(a, b, r, c);       for (int(j) = (0); (j) < (y); ++(j)) flipH(a, b, r, c);       for (int(j) = (0); (j) < (z); ++(j)) rotate(a, b, r, c);       printf( %d %d n , a, b);     }     return 0;   }   