#include <bits/stdc++.h>
int n, m, i;
int step, q[1000010][3], visited[2][100001];
char ar[2][100001];
int f = -1, r = -1, k = 0;
int bfs(int v, int w, int water) {
  if ((w + 1 >= n) || (w + step >= n)) {
    printf("YES");
    return 0;
  }
  if ((w - 2) >= water && ar[v][w - 1] == '-') {
    if (visited[v][w - 1] != 1) {
      r++;
      q[r][0] = v;
      q[r][1] = w - 1;
      q[r][2] = water + 1;
      visited[v][w - 1] = 1;
    }
  }
  if (ar[v][w + 1] == '-') {
    if (visited[v][w + 1] != 1) {
      r++;
      q[r][0] = v;
      q[r][1] = w + 1;
      q[r][2] = water + 1;
      visited[v][w + 1] = 1;
    }
  }
  if (ar[(v + 1) % 2][w + step] == '-') {
    if (visited[(v + 1) % 2][w + step] != 1) {
      r++;
      q[r][0] = (v + 1) % 2;
      q[r][1] = w + step;
      q[r][2] = water + 1;
      visited[(v + 1) % 2][w + step] = 1;
    }
  }
  if (f < r) {
    f++;
    return bfs(q[f][0], q[f][1], q[f][2]);
  }
  return 1;
}
int main() {
  int j, res;
  char temp;
  scanf("%i", &n);
  scanf("%i", &step);
  for (i = 0; i < 2; i++) {
    j = 0;
    while (j < n) {
      scanf("%c", &temp);
      if (temp != '\n') {
        ar[i][j] = temp;
        j++;
      }
    }
  }
  res = bfs(0, 0, 0);
  if (res == 1) printf("NO");
  return 0;
}
