#include <bits/stdc++.h>
using namespace std;
char b[2][111111];
int er[2][111111];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  scanf("%s", &b[0]);
  scanf("%s", &b[1]);
  queue<pair<int, int> > q;
  memset(er, -1, sizeof(er));
  q.push(make_pair(0, 0));
  er[0][0] = 0;
  while (!q.empty()) {
    pair<int, int> i;
    i.first = q.front().first;
    i.second = q.front().second;
    q.pop();
    if (i.second < er[i.first][i.second]) continue;
    if (i.second + k >= n) {
      printf("%s", "YES");
      return 0;
    }
    if (b[i.first][i.second + 1] == '-' && er[i.first][i.second + 1] == -1) {
      er[i.first][i.second + 1] = er[i.first][i.second] + 1;
      q.push(make_pair(i.first, i.second + 1));
    }
    if (b[i.first][i.second - 1] == '-' && er[i.first][i.second - 1] == -1 &&
        i.second > 0) {
      er[i.first][i.second - 1] = er[i.first][i.second] + 1;
      q.push(make_pair(i.first, i.second - 1));
    }
    if (b[!i.first][i.second + k] == '-' && er[!i.first][i.second + k] == -1) {
      er[!i.first][i.second + k] = er[i.first][i.second] + 1;
      q.push(make_pair(!i.first, i.second + k));
    }
  }
  printf("%s", "NO");
  return 0;
}
