#include <bits/stdc++.h>
using namespace std;
int ans, n, m;
struct node {
  int x, y;
} q[500010];
int vis[500010][2];
char g[2][500010];
int bfs() {
  int front = 0, rear = 1;
  node t;
  t.x = 0, t.y = 0;
  memset(vis, -1, sizeof(vis));
  q[front] = t;
  vis[t.x][t.y] = 0;
  while (front < rear) {
    node u = q[front++];
    int x = u.x;
    int y = u.y;
    if (x + m >= n) return 1;
    if (g[y][x + 1] == '-') {
      if (vis[x + 1][y] < 0) {
        vis[x + 1][y] = vis[x][y] + 1;
        if (vis[x + 1][y] <= x + 1) {
          node t;
          t.x = x + 1;
          t.y = y;
          q[rear++] = t;
        }
      }
    }
    if (x > 0 && g[y][x - 1] == '-') {
      if (vis[x - 1][y] < 0) {
        vis[x - 1][y] = vis[x][y] + 1;
        if (vis[x - 1][y] <= x - 1) {
          node t;
          t.x = x - 1;
          t.y = y;
          q[rear++] = t;
        }
      }
    }
    if (g[!y][x + m] == '-') {
      if (vis[x + m][!y] < 0) {
        vis[x + m][!y] = vis[x][y] + 1;
        if (vis[x + m][!y] <= x + m) {
          node t;
          t.x = x + m;
          t.y = !y;
          q[rear++] = t;
        }
      }
    }
  }
  return 0;
}
int main() {
  int i, j;
  while (scanf("%d%d", &n, &m) != EOF) {
    scanf("%s%s", g[0], g[1]);
    int ans = bfs();
    if (ans)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
