#include <bits/stdc++.h>
using namespace std;
template <typename T>
void mymax(T &_a, T _b) {
  if (_a < _b) _a = _b;
}
template <typename T>
void mymin(T &_a, T _b) {
  if (_a > _b) _a = _b;
}
void print(int _x) { printf("%d ", _x); }
void print(long long _x) { printf("%I64d ", _x); }
struct Event {
  bool side;
  int h;
  int time;
  Event() {}
  Event(bool ss, int hh, int tt) {
    side = ss;
    h = hh;
    time = tt;
  }
};
bool operator<(Event e1, Event e2) { return e1.h < e2.h; }
int n, k;
bool cango[2][100005 * 2];
int wenttime[2][100005 * 2];
queue<Event> q;
int deal_event() {
  q.push(Event(0, 1, 0));
  while (!q.empty()) {
    Event now = q.front();
    q.pop();
    if (now.h > n - k) return now.time + 1;
    if (cango[now.side][now.h - 1] && now.h - 1 > now.time + 1 &&
        !wenttime[now.side][now.h - 1]) {
      wenttime[now.side][now.h - 1] = now.time + 1;
      q.push(Event(now.side, now.h - 1, now.time + 1));
    }
    if (cango[now.side][now.h + 1] && !wenttime[now.side][now.h + 1]) {
      if (now.h + 1 > n - k) return now.time + 1;
      wenttime[now.side][now.h + 1] = now.time + 1;
      q.push(Event(now.side, now.h + 1, now.time + 1));
    }
    if (cango[now.side ^ 1][now.h + k] && !wenttime[now.side ^ 1][now.h + k]) {
      wenttime[now.side ^ 1][now.h + k] = now.time + 1;
      if (now.h + k > n - k) return now.time + 1;
      q.push(Event(now.side ^ 1, now.h + k, now.time + 1));
    }
  }
  return 0;
}
int main() {
  scanf("%d %d", &n, &k);
  getchar();
  for (int i = 1; i <= n * 2; i++) {
    cango[0][i] = cango[1][i] = 1;
    wenttime[0][i] = wenttime[1][i] = 0;
  }
  for (int j = 0; j <= 1; j++) {
    for (int i = 1; i <= n; i++) {
      char c;
      c = getchar();
      if (c == '-')
        cango[j][i] = 1;
      else
        cango[j][i] = 0;
    }
    getchar();
  }
  int ans = deal_event();
  if (ans)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
