func_code_string: #include <bits/stdc++.h>   using namespace std;   bool boy[1000], girl[1000];   int n, m, b, g, x, y, q[1000][2], h, t;   int main() {     memset(boy, false, sizeof(boy));     scanf( %d%d%d , &n, &m, &b);     for (int i = 1; i <= b; i++) {       scanf( %d , &x);       boy[x] = true;     }     memset(girl, false, sizeof(girl));     scanf( %d , &g);     for (int i = 1; i <= g; i++) {       scanf( %d , &y);       girl[y] = true;     }     h = t = 0;     for (int i = 0; i < n; i++)       if (boy[i]) {         t++;         q[t][1] = 0;         q[t][2] = i;       }     for (int i = 0; i < m; i++)       if (girl[i]) {         t++;         q[t][1] = 1;         q[t][2] = i;       }     while (h < t) {       h++;       if (q[h][1]) {         int u = q[h][2] % n;         for (int i = 1; i <= n; i++) {           if (!boy[u]) {             boy[u] = true;             t++;             q[t][1] = 0;             q[t][2] = u;           }           u = (u + m) % n;         }       } else {         int u = q[h][2] % m;         for (int i = 1; i <= m; i++) {           if (!girl[u]) {             girl[u] = true;             t++;             q[t][1] = 1;             q[t][2] = u;           }           u = (u + n) % m;         }       }     }     if (t == n + m)       puts( Yes );     else       puts( No );     return 0;   }   