#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > q;
int a[100005], b[100005], chk1[100005], chk2[100005];
int main() {
  int n, k;
  char c;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    do {
      scanf("%c", &c);
    } while (c == ' ' || c == '\n');
    if (c == '-')
      a[i] = 0;
    else
      a[i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    do {
      scanf("%c", &c);
    } while (c == ' ' || c == '\n');
    if (c == '-')
      b[i] = 0;
    else
      b[i] = 1;
  }
  int now, flood, chk = 0;
  pair<int, int> dmp, pdmp;
  chk1[1] = 1;
  chk2[1] = 1;
  dmp.first = 1;
  dmp.second = 0;
  q.push(dmp);
  dmp.first = -1;
  dmp.second = 0;
  while (!q.empty()) {
    dmp = q.front();
    q.pop();
    chk = 1;
    if (dmp.first < 0) {
      chk = 2;
      dmp.first = -dmp.first;
    }
    now = dmp.first;
    flood = dmp.second;
    dmp.second = flood + 1;
    if (now + k > n) {
      printf("YES");
      return 0;
    }
    if (chk == 1) {
      if (a[now + 1] == 0 && !chk1[now + 1]) {
        chk1[now + 1] = 1;
        dmp.first = now + 1;
        q.push(dmp);
      }
      if (now != 0) {
        if (a[now - 1] == 0 && flood + 1 < now && !chk1[now - 1]) {
          chk1[now - 1] = 1;
          dmp.first = now - 1;
          q.push(dmp);
        }
      }
      if (b[now + k] == 0 && !chk2[now + k]) {
        chk2[now + k] = 1;
        dmp.first = -(now + k);
        q.push(dmp);
      }
    } else {
      if (b[now + 1] == 0 && !chk2[now + 1]) {
        chk2[now + 1] = 1;
        dmp.first = -(now + 1);
        q.push(dmp);
      }
      if (now != 0) {
        if (b[now - 1] == 0 && flood + 1 < now - 1 && !chk2[now - 1]) {
          chk2[now - 1] = 1;
          dmp.first = -(now - 1);
          q.push(dmp);
        }
      }
      if (a[now + k] == 0 && !chk1[now + k]) {
        chk1[now + k] = 1;
        dmp.first = (now + k);
        q.push(dmp);
      }
    }
  }
  printf("NO");
}
