#include <bits/stdc++.h>
using namespace std;
struct QNode {
  int h, s, t;
  QNode(int h, int s, int t) : h(h), s(s), t(t) {}
  QNode() {}
};
const int H = 100005;
int vis[H][2];
QNode que[H * 2];
bool a[H][2];
int n, k;
bool judge() {
  int head, tail, i, j, d, i1, j1, t;
  head = tail = 0;
  que[head] = QNode(0, 0, 0);
  memset(vis, -1, sizeof vis);
  vis[que[head].h][que[head].s] = 0;
  while (head <= tail) {
    i = que[head].h;
    j = que[head].s;
    t = que[head].t;
    for (d = 0; d < 3; d++) {
      if (d == 0)
        i1 = i + 1, j1 = j;
      else if (d == 1)
        i1 = i - 1, j1 = j;
      else if (d == 2)
        i1 = i + k, j1 = 1 - j;
      if (i1 >= 0 and (i1 >= n or (not a[i1][j1]) and vis[i1][j1] == -1) and
          i1 >= t + 1) {
        if (i1 > n) return true;
        que[++tail] = QNode(i1, j1, t + 1);
        vis[i1][j1] = t + 1;
      }
    }
    head++;
  }
  return false;
}
int main() {
  int i, j;
  cin >> n >> k;
  char c;
  for (j = 0; j < 2; j++)
    for (i = 0; i < n; i++) {
      cin >> c;
      a[i][j] = (c == '-' ? 0 : 1);
    }
  if (judge()) {
    cout << "YES\n";
  } else
    cout << "NO\n";
  return 0;
}
