#include <bits/stdc++.h>
using namespace std;
struct node {
  int stemp;
  int x, y;
} D, d;
queue<node> q;
char Map[4][201005];
int book[4][201005];
int main() {
  int n, k;
  int next[4][2] = {{0, 1}, {0, -1}, {1, 1}, {-1, 1}};
  int i, j, f;
  while (cin >> n >> k) {
    memset(Map, 0, sizeof(Map));
    memset(book, 0, sizeof(book));
    getchar();
    for (i = 1; i <= 2; i++) {
      for (j = 1; j <= n; j++) cin >> Map[i][j];
      getchar();
    }
    D.stemp = 0;
    D.x = 1;
    D.y = 1;
    book[D.x][D.y] = 1;
    while (!q.empty()) q.pop();
    q.push(D);
    f = 0;
    while (!q.empty()) {
      D = q.front();
      q.pop();
      if (D.y >= n) {
        f = 1;
        printf("YES\n");
        break;
      }
      for (i = 0; i < 4; i++) {
        d.stemp = D.stemp + 1;
        if (i < 2) {
          d.x = D.x + next[i][0];
          d.y = D.y + next[i][1];
        } else {
          d.x = D.x + next[i][0];
          d.y = D.y + next[i][1] * k;
        }
        if (d.x < 1 || d.x > 2 || d.y < 1) continue;
        if (Map[d.x][d.y] == 'X') continue;
        if (d.y <= d.stemp) continue;
        if (book[d.x][d.y] == 1) continue;
        q.push(d);
        book[d.x][d.y] = 1;
      }
    }
    if (f == 0) printf("NO\n");
  }
}
