#include <bits/stdc++.h>
using namespace std;
int n, k;
bool vst[200000];
int dist[200000];
char str[100010];
int dat[200000];
int q[210000], l, r;
int main() {
  scanf("%d%d", &n, &k);
  memset(dat, 0, sizeof(dat));
  memset(vst, 0, sizeof(vst));
  for (int i = 0; i < 200000; ++i) dist[i] = 1000000000;
  for (int i = 0; i <= 1; ++i) {
    scanf("%s", str);
    for (int j = 0; j < n; ++j) dat[(j << 1) | i] = (str[j] == '-');
  }
  vst[0] = 1;
  l = 1;
  r = 1;
  q[1] = 0;
  dist[0] = 0;
  while (l <= r) {
    int now = q[l++], next;
    next = now - 2;
    if (((next) >= 0) && (!vst[next]) && dat[next] && (dist[now] < next / 2)) {
      vst[next] = 1;
      q[++r] = next;
      dist[next] = dist[now] + 1;
    }
    next = now + 2;
    if (((next) < (n << 1)) && (!vst[next]) && dat[next] &&
        (dist[now] < next / 2)) {
      vst[next] = 1;
      q[++r] = next;
      dist[next] = dist[now] + 1;
    }
    next = (now + (k << 1)) ^ 1;
    if ((next >= 0) && (next < (n << 1)) && (!vst[next]) && dat[next] &&
        (dist[now] < next / 2)) {
      vst[next] = 1;
      q[++r] = next;
      dist[next] = dist[now] + 1;
    }
  }
  int res = 1000000000;
  for (int i = n - k; i < n; ++i)
    res = min(res, min(dist[i << 1], dist[(i << 1) | 1]));
  printf("%s\n", (res < 1000000000) ? "YES" : "NO");
  return 0;
}
