func_code_string: #include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long f = 0, s = 0;     char c = getchar();     while (c >  9  || c <  0 ) f = (c ==  - ), c = getchar();     while (c >=  0  && c <=  9 )       s = (s << 3) + (s << 1) + (c ^  0 ), c = getchar();     return f ? -s : s;   }   long long n, m, k;   vector<long long> ch[200005];   vector<long long> he[200005];   long long it1, it2;   long long t1, t2;   long long sx, sy, sfx;   long long tx, ty, tfx;   long long nx, ny;   char cc[5];   long long ans = 0;   bool flag = 0;   inline long long ne(long long op, long long t, long long x) {     if (op == 1)       return ch[t][upper_bound(ch[t].begin(), ch[t].end(), x) - ch[t].begin()];     else       return he[t][upper_bound(he[t].begin(), he[t].end(), x) - he[t].begin()];   }   inline long long ft(long long op, long long t, long long x) {     if (op == 1)       return ch[t]                [lower_bound(ch[t].begin(), ch[t].end(), x) - ch[t].begin() - 1];     else       return he[t]                [lower_bound(he[t].begin(), he[t].end(), x) - he[t].begin() - 1];   }   inline long long fd(long long op, long long t, long long x) {     if (op == 1) {       long long tt = lower_bound(ch[t].begin(), ch[t].end(), x) - ch[t].begin();       if (tt >= ch[t].size()) return -1;       if (ch[t][tt] == x)         return tt;       else         return -1;     } else {       long long tt = lower_bound(he[t].begin(), he[t].end(), x) - he[t].begin();       if (tt >= he[t].size()) return -1;       if (he[t][tt] == x)         return tt;       else         return -1;     }   }   bool ff = 1, fff = 1;   int main() {     n = read();     m = read();     k = read();     for (int i = 1; i <= k; i++) {       t1 = read();       t2 = read();       ch[t2 - t1 + n + 1].push_back(t1);       he[t1 + t2].push_back(t1);     }     for (int i = 0; i <= n + 1; i++) {       ch[m + 1 - i + n + 1].push_back(i);       he[m + 1 + i].push_back(i);       ch[-i + n + 1].push_back(i);       he[i].push_back(i);     }     for (int i = 0; i <= m + 1; i++) {       ch[i + n + 1].push_back(0);       he[i].push_back(0);       ch[i - n - 1 + n + 1].push_back(n + 1);       he[n + 1 + i].push_back(n + 1);     }     for (int i = 0; i <= n + m + 2; i++) sort(he[i].begin(), he[i].end());     for (int i = 0; i <= m + n + 2; i++) sort(ch[i].begin(), ch[i].end());     sx = read();     sy = read();     scanf( %s , cc);     if (cc[0] ==  N ) {       if (cc[1] ==  E )         sfx = 0;       else         sfx = 1;     } else {       if (cc[1] ==  E )         sfx = 2;       else         sfx = 3;     }     tx = sx;     ty = sy;     tfx = sfx;     sx = sy = sfx = -1;     while (tx != sx || ty != sy || tfx != sfx || fff) {       if (fff && tx == sx && ty == sy && tfx == sfx) fff = 0;       if (tfx == 0) {         nx = ne(2, tx + ty, tx);         ny = tx + ty - nx;         ans += nx - tx;         it1 = fd(2, tx + ty - 1, nx - 1);         it2 = fd(2, tx + ty + 1, nx);         if (it1 != -1 && it2 != -1) {           tfx = 3;           tx = nx - 1;           ty = ny + 1;           flag = 1;         } else if (it1 != -1) {           tfx = 2;           tx = nx;           ty = ny + 1;         } else if (it2 != -1) {           tfx = 1;           tx = nx - 1;           ty = ny;         } else {           tfx = 3;           tx = nx - 1;           ty = ny + 1;           flag = 1;         }       } else if (tfx == 3) {         nx = ft(2, tx + ty, tx);         ny = tx + ty - nx;         ans += tx - nx;         it1 = fd(2, tx + ty - 1, nx);         it2 = fd(2, tx + ty + 1, nx + 1);         if (it1 != -1 && it2 != -1) {           tfx = 0;           tx = nx + 1;           ty = ny - 1;           flag = 1;         } else if (it1 != -1) {           tfx = 2;           tx = nx + 1;           ty = ny;         } else if (it2 != -1) {           tfx = 1;           tx = nx;           ty = ny - 1;         } else {           tfx = 0;           tx = nx + 1;           ty = ny - 1;           flag = 1;         }       } else if (tfx == 2) {         nx = ne(1, ty - tx + n + 1, tx);         ny = ty - tx + nx;         ans += nx - tx;         it1 = fd(1, ty - tx + n + 1 - 1, nx);         it2 = fd(1, ty - tx + n + 1 + 1, nx - 1);         if (it1 != -1 && it2 != -1) {           tfx = 1;           tx = nx - 1;           ty = ny - 1;           flag = 1;         } else if (it1 != -1) {           tfx = 3;           tx = nx - 1;           ty = ny;         } else if (it2 != -1) {           tfx = 0;           tx = nx;           ty = ny - 1;         } else {           tfx = 1;           tx = nx - 1;           ty = ny - 1;           flag = 1;         }       } else if (tfx == 1) {         nx = ft(1, ty - tx + n + 1, tx);         ny = ty - tx + nx;         ans += tx - nx;         it1 = fd(1, ty - tx + n + 1 - 1, nx + 1);         it2 = fd(1, ty - tx + n + 1 + 1, nx);         if (it1 != -1 && it2 != -1) {           tfx = 2;           tx = nx + 1;           ty = ny + 1;           flag = 1;         } else if (it1 != -1) {           tfx = 3;           tx = nx;           ty = ny + 1;         } else if (it2 != -1) {           tfx = 0;           tx = nx + 1;           ty = ny;         } else {           tfx = 2;           tx = nx + 1;           ty = ny + 1;           flag = 1;         }       }       if (ff) {         sx = tx;         sy = ty;         sfx = tfx;         ff = 0;         ans = 0;       }     }     while (tx != sx || ty != sy || tfx != sfx)       ;     if (flag)       printf( %lld , ans / 2);     else       printf( %lld , ans);     return 0;   }   