#include <bits/stdc++.h>
using namespace std;
struct Node {
  int x, y, z;
};
int n, m;
char a[5][1000005];
int bfs() {
  Node node;
  queue<Node> q;
  node.x = 0;
  node.y = 0;
  node.z = 0;
  q.push(node);
  while (!q.empty()) {
    Node cur = q.front();
    q.pop();
    if (cur.y >= n - 1) return 1;
    if (a[cur.x][cur.y + 1] != 'X' && cur.y + 1 > cur.z) {
      a[cur.x][cur.y + 1] = 'X';
      node.x = cur.x;
      node.y = cur.y + 1;
      node.z = cur.z + 1;
      q.push(node);
    }
    if (a[cur.x][cur.y - 1] != 'X' && cur.y - 1 > cur.z) {
      a[cur.x][cur.y - 1] = 'X';
      node.x = cur.x;
      node.y = cur.y - 1;
      node.z = cur.z + 1;
      q.push(node);
    }
    if (a[(cur.x + 1) % 2][cur.y + m] != 'X' && cur.y + m > cur.z) {
      a[(cur.x + 1) % 2][cur.y + m] = 'X';
      node.x = (cur.x + 1) % 2;
      node.y = cur.y + m;
      node.z = cur.z + 1;
      q.push(node);
    }
  }
  return 0;
}
int main() {
  int i, j;
  while (cin >> n >> m) {
    memset(a, 'a', sizeof(a));
    for (i = 0; i < 2; i++) {
      for (j = 0; j < n; j++) cin >> a[i][j];
    }
    if (bfs())
      printf("YES\n");
    else
      printf("NO\n");
  }
}
