#include <bits/stdc++.h>
using std::queue;
struct Node {
  int cur, l, depth;
};
int n, k;
char buff[131072];
char t;
bool map[262144][2], mark[262144][2];
queue<Node> Q;
bool go(int cur, int l, int depth) {
  Node tmp;
  tmp.cur = cur;
  tmp.l = l;
  tmp.depth = depth;
  Q.push(tmp);
  while (!Q.empty()) {
    tmp = Q.front();
    cur = tmp.cur;
    l = tmp.l;
    depth = tmp.depth;
    if (cur < depth) {
      Q.pop();
      continue;
    }
    if (cur >= n) return true;
    if ((!mark[cur + k][l ^ 1]) && map[cur + k][l ^ 1]) {
      mark[cur + k][l ^ 1] = true;
      tmp.cur = cur + k;
      tmp.l = l ^ 1;
      tmp.depth = depth + 1;
      Q.push(tmp);
    }
    if ((!mark[cur + 1][l]) && map[cur + 1][l]) {
      mark[cur + 1][l] = true;
      tmp.cur = cur + 1;
      tmp.l = l;
      tmp.depth = depth + 1;
      Q.push(tmp);
    }
    if (cur > 0)
      if ((!mark[cur - 1][l]) && map[cur - 1][l]) {
        mark[cur - 1][l] = true;
        tmp.cur = cur - 1;
        tmp.l = l;
        tmp.depth = depth + 1;
        Q.push(tmp);
      }
    Q.pop();
  }
  return false;
}
int main() {
  memset(map, true, sizeof(map));
  scanf("%d%d", &n, &k);
  gets(buff);
  register int i;
  for (i = 0; i < n; ++i) {
    scanf("%c", &t);
    map[i][0] = (t == '-');
  }
  gets(buff);
  for (i = 0; i < n; i++) {
    scanf("%c", &t);
    map[i][1] = (t == '-');
  }
  if (go(0, 0, 0))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
