#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, X, Y, Z, p;     int x, y;     while (scanf( %d%d%d%d%d%d , &n, &m, &X, &Y, &Z, &p) != EOF) {       X %= 4;       Y %= 2;       Z %= 4;       int tn = n;       int tm = m;       for (int i = 1; i <= p; i++) {         n = tn;         m = tm;         scanf( %d%d , &x, &y);         if (X == 1) {           int xx = x;           x = y;           y = n + 1 - xx;           int nn = n;           n = m;           m = nn;         } else if (X == 2) {           x = n + 1 - x;           y = m + 1 - y;         } else if (X == 3) {           int xx = x;           x = m + 1 - y;           y = xx;           int nn = n;           n = m;           m = nn;         }         if (Y == 1) {           y = m + 1 - y;         }         if (Z == 1) {           int xx = x;           x = m + 1 - y;           y = xx;           int nn = n;           n = m;           m = nn;         } else if (Z == 2) {           x = n + 1 - x;           y = m + 1 - y;         } else if (Z == 3) {           int xx = x;           x = y;           y = n + 1 - xx;           int nn = n;           n = m;           m = nn;         }         printf( %d %d n , x, y);       }     }     return 0;   }   