#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 100 * 10 * 3 + 10;
int mn[MAXN][2];
queue<int> q;
int main() {
  int n, m;
  cin >> n >> m;
  string s[2];
  for (int i = 0; i < MAXN; i++) mn[i][0] = mn[i][1] = -1;
  cin >> s[0] >> s[1];
  mn[0][0] = 0;
  q.push(0);
  q.push(0);
  int t = 0;
  int x, y, k;
  bool flag = false;
  while (q.size()) {
    x = q.front();
    q.pop();
    y = q.front();
    q.pop();
    if (x + 1 > n or x + m > n) {
      flag = true;
      break;
    }
    if (s[y][x + 1] != 'X' and x + 1 <= m + n and mn[x + 1][y] == -1) {
      q.push(x + 1), q.push(y);
      mn[x + 1][y] = k + 1;
    }
    if (x - 1 >= 0 and s[y][x - 1] != 'X' and mn[x - 1][y] == -1 and
        x - 1 > mn[x][y]) {
      q.push(x - 1), q.push(y);
      mn[x - 1][y] = mn[x][y] + 1;
    }
    if (x + m <= n + m and s[1 - y][x + m] != 'X' and mn[x + m][1 - y] == -1) {
      q.push(x + m), q.push(1 - y);
      mn[x + m][1 - y] = mn[x][y] + 1;
    }
    if (s[1 - y][x + m] != 'X' and mn[x - m][1 - y] == -1 and x - m >= 0 and
        x - m > mn[x][y]) {
      q.push(x - m), q.push(1 - y);
      mn[x - m][1 - y] = mn[x][y] + 1;
    }
  }
  for (int i = n; i <= n + m; i++)
    if (mn[i][0] > 0 or mn[i][1] > 0) flag = true;
  if (flag == true)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
