#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
queue<int> q;
char c[2][100100];
int d[200200];
int n, m;
int main() {
  cin >> n >> m;
  cin >> c[0] >> c[1];
  memset(d, 0x3f, sizeof(d));
  q.push(0);
  d[0] = 0;
  int res = INF;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    int side = t / n;
    int pos = t % n;
    if (pos + m >= n) {
      res = d[t] + m;
      break;
    }
    if (c[side][pos + 1] == '-' && d[side * n + pos + 1] == INF) {
      d[side * n + pos + 1] = d[t] + 1;
      q.push(side * n + pos + 1);
    }
    if (c[1 - side][pos + m] == '-' && d[(1 - side) * n + pos + m] == INF) {
      d[(1 - side) * n + pos + m] = d[t] + 1;
      q.push((1 - side) * n + pos + m);
    }
    if (c[side][pos - 1] == '-' && d[side * n + pos - 1] == INF && pos > 0 &&
        pos - 1 >= d[t] + 1) {
      d[side * n + pos - 1] = d[t] + 1;
      q.push(side * n + pos - 1);
    }
  }
  if (res == INF)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
