#include <bits/stdc++.h>
using namespace std;
int n, k, wl[100005], wr[100005];
char l[100005], r[100005];
bool visL[100005], visR[100005];
bool bfs() {
  queue<pair<int, char> > q;
  q.push(make_pair(1, 'l'));
  visL[1] = true;
  wl[1] = 0;
  while (!q.empty()) {
    int x = q.front().first;
    char d = q.front().second;
    q.pop();
    if (x + k > n) return true;
    if (d == 'l') {
      if (l[x + 1] == '-' && !visL[x + 1]) {
        q.push(make_pair(x + 1, d));
        visL[x + 1] = true;
        wl[x + 1] = wl[x] + 1;
      }
      if (x != 1 && x - 1 > wl[x] + 1 && l[x - 1] == '-' && !visL[x - 1]) {
        q.push(make_pair(x - 1, d));
        visL[x - 1] = true;
        wl[x - 1] = wl[x] + 1;
      }
      if (r[x + k] == '-' && !visR[x + k]) {
        q.push(make_pair(x + k, 'r'));
        visR[x + k] = true;
        wr[x + k] = wl[x] + 1;
      }
    } else {
      if (r[x + 1] == '-' && !visR[x + 1]) {
        q.push(make_pair(x + 1, d));
        visR[x + 1] = true;
        wr[x + 1] = wr[x] + 1;
      }
      if (x != 1 && x - 1 > wr[x] + 1 && r[x - 1] == '-' && !visR[x - 1]) {
        q.push(make_pair(x - 1, d));
        visR[x - 1] = true;
        wr[x - 1] = wr[x] + 1;
      }
      if (l[x + k] == '-' && !visL[x + k]) {
        q.push(make_pair(x + k, 'l'));
        visL[x + k] = true;
        wl[x + k] = wr[x] + 1;
      }
    }
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf(" %c", &l[i]);
  for (int i = 1; i <= n; i++) scanf(" %c", &r[i]);
  if (bfs())
    printf("YES");
  else
    printf("NO");
  return 0;
}
