func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     int n, m;     cin >> n >> m;     vector<char> A(n * 2);     for (int i = 0; i < n * 2; i++) cin >> A[i];     vector<vector<pair<int, int> > > table(n * 2, vector<pair<int, int> >(20));     for (int i = 0; i < n * 2; i++) {       if (A[i] ==  X  || i == n - 1 || i == n * 2 - 1)         table[i][0] = make_pair(-1, -1);       else {         if (A[i + 1] ==  . )           table[i][0] = make_pair(i + 1, 1);         else {           int num = (i < n ? i + n : i - n);           if (A[num] ==  . )             table[i][0] = make_pair(num, 1);           else             table[i][0] = make_pair(-1, -1);         }       }     }     for (int k = 1; k < 20; k++) {       for (int i = 0; i < n * 2; i++) {         if (table[i][k - 1].first == -1)           table[i][k] = make_pair(-1, -1);         else {           pair<int, int> p = table[i][k - 1];           table[i][k] = make_pair(table[p.first][k - 1].first,                                   p.second + table[p.first][k - 1].second);         }       }     }     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       a--, b--;       if (a % n > b % n) swap(a, b);       int k = 19;       int res = 0;       while (k >= 0) {         if (table[a][k].first != -1 && table[a][k].first % n < b % n) {           res += table[a][k].second;           a = table[a][k].first;         }         k--;       }       if (a % n != b % n) {         if (A[a + 1] ==  . )           a = a + 1, res++;         else {           a = a < n ? a + n : a - n, res++;           if (A[a] ==  X ) {             cout <<  -1 n ;             continue;           }           if (A[a + 1] ==  . )             a = a + 1, res++;           else {             cout <<  -1 n ;             continue;           }         }       }       if (a == b)         cout << res <<   n ;       else {         if (A[a < n ? a + n : a - n] ==  . ) {           a = (a < n ? a + n : a - n), res++;           if (a == b)             cout << res <<   n ;           else             cout <<  -1 n ;         } else           cout <<  -1 n ;       }     }     return 0;   }   