#include <bits/stdc++.h>
using namespace std;
struct Item {
  int w;
  int i;
  int j;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<vector<char> > a(2, vector<char>(1 + n + k, '-'));
  for (int i = 0; i < 2; ++i) {
    for (int j = 1; j <= n; ++j) {
      cin >> a[i][j];
    }
  }
  vector<vector<bool> > used(2, vector<bool>(1 + n + k, 0));
  used[0][1] = 1;
  queue<Item> q;
  q.push(Item{0, 0, 1});
  while (!q.empty()) {
    Item cur = q.front();
    q.pop();
    if (cur.j > n) {
      cout << "YES";
      return 0;
    }
    int nw = cur.w + 1, ni, nj;
    ni = cur.i, nj = cur.j - 1;
    if (nj >= 1 && nw < nj && a[ni][nj] == '-' && !used[ni][nj]) {
      used[ni][nj] = 1;
      q.push(Item{nw, ni, nj});
    }
    ni = cur.i, nj = cur.j + 1;
    if (nj >= 1 && nw < nj && a[ni][nj] == '-' && !used[ni][nj]) {
      used[ni][nj] = 1;
      q.push(Item{nw, ni, nj});
    }
    ni = (cur.i + 1) % 2, nj = cur.j + k;
    if (nj >= 1 && nw < nj && a[ni][nj] == '-' && !used[ni][nj]) {
      used[ni][nj] = 1;
      q.push(Item{nw, ni, nj});
    }
  }
  cout << "NO";
  return 0;
}
