#include <bits/stdc++.h>
using namespace std;
const int maxn = 100008;
int n, k;
char A[maxn][2];
queue<int> loc, lev, stp;
bool bk[maxn][2];
int main() {
  cin >> n >> k;
  int i, h, l, s;
  getchar();
  for (i = 1; i <= n; i++) {
    A[i][0] = getchar();
  }
  getchar();
  for (i = 1; i <= n; i++) {
    A[i][1] = getchar();
  }
  if (A[1][0] == '-') {
    loc.push(0);
    lev.push(1);
    stp.push(0);
    bk[1][0] = 1;
  }
  while (!lev.empty()) {
    l = loc.front();
    loc.pop();
    h = lev.front();
    lev.pop();
    s = stp.front();
    stp.pop();
    if (h + 1 > n || h + k > n) {
      puts("YES");
      return 0;
    }
    if (bk[h + 1][l] == 0 && A[h + 1][l] == '-') {
      bk[h + 1][l] = 1;
      loc.push(l);
      lev.push(h + 1);
      stp.push(s + 1);
    }
    if (bk[h + k][!l] == 0 && A[h + k][!l] == '-') {
      bk[h + k][!l] = 1;
      loc.push(!l);
      lev.push(h + k);
      stp.push(s + 1);
    }
    if (h - 1 > s + 1 && bk[h - 1][l] == 0 && A[h - 1][l] == '-') {
      bk[h - 1][l] = 1;
      loc.push(l);
      lev.push(h - 1);
      stp.push(s + 1);
    }
  }
  puts("NO");
  return 0;
}
