#include <bits/stdc++.h>
using namespace std;
const int INF = 20050226;
char wall[2][200005];
int co[2][200005];
int n, m;
int ans = INF;
void go() {
  queue<pair<pair<int, int>, int> > q;
  q.push(make_pair(make_pair(0, 0), -1));
  co[0][0] = 0;
  while (!q.empty()) {
    int h = q.front().first.first;
    int p = q.front().first.second;
    int sc = q.front().second;
    q.pop();
    if (h >= n) {
      ans = min(ans, sc);
      break;
    }
    if (h - 1 > sc + 1 and wall[p][h - 1] != 'X') {
      if (co[p][h - 1] > co[p][h] + 1) {
        co[p][h - 1] = co[p][h] + 1;
        q.push(make_pair(make_pair(h - 1, p), sc + 1));
      }
    }
    if (wall[p][h + 1] != 'X') {
      if (co[p][h + 1] > co[p][h] + 1) {
        co[p][h + 1] = co[p][h] + 1;
        q.push(make_pair(make_pair(h + 1, p), sc + 1));
      }
    }
    if (p == 0) {
      if (wall[1][h + m] != 'X') {
        if (co[1][h + m] > co[0][h] + 1) {
          co[1][h + m] = co[0][h] + 1;
          q.push(make_pair(make_pair(h + m, 1), sc + 1));
        }
      }
    }
    if (p == 1) {
      if (wall[0][h + m] != 'X') {
        if (co[0][h + m] > co[1][h] + 1) {
          co[0][h + m] = co[1][h] + 1;
          q.push(make_pair(make_pair(h + m, 0), sc + 1));
        }
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> wall[0][i];
  }
  for (int i = 0; i < n; i++) {
    cin >> wall[1][i];
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 200005; j++) {
      co[i][j] = INF;
    }
  }
  go();
  if (ans == INF) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
