#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
const long long mod = 1e9 + 7;
const long long inf = 8e18;
char a[2][maxn];
bool visited[2][maxn];
long long d[2][maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[0][i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[1][i];
  }
  queue<pair<long long, long long> > pq;
  pair<long long, long long> w;
  pair<long long, long long> p;
  w.first = 0;
  w.second = 1;
  visited[w.first][w.second] = 1;
  pq.push(w);
  while (!pq.empty()) {
    w = pq.front();
    pq.pop();
    if (d[w.first][w.second] <= n - 1 && w.second == n) {
      cout << "YES";
      return 0;
    }
    if (w.second != n) {
      if (a[w.first][w.second + 1] == '-' &&
          visited[w.first][w.second + 1] == 0) {
        visited[w.first][w.second + 1] = 1;
        d[w.first][w.second + 1] = d[w.first][w.second] + 1;
        p.first = w.first;
        p.second = w.second + 1;
        pq.push(p);
      }
    }
    if (w.second != 0 && w.second - 1 > d[w.first][w.second] + 1) {
      if (a[w.first][w.second - 1] == '-' &&
          visited[w.first][w.second - 1] == 0) {
        visited[w.first][w.second - 1] = 1;
        d[w.first][w.second - 1] = d[w.first][w.second] + 1;
        p.first = w.first;
        p.second = w.second - 1;
        pq.push(p);
      }
    }
    if (w.second + k > n) {
      cout << "YES";
      return 0;
    }
    if (a[(w.first + 1) % 2][w.second + k] == '-') {
      if (visited[(w.first + 1) % 2][w.second + k] == 0) {
        visited[(w.first + 1) % 2][w.second + k] = 1;
        d[(w.first + 1) % 2][w.second + k] = d[w.first][w.second] + 1;
        p.first = (w.first + 1) % 2;
        p.second = w.second + k;
        pq.push(p);
      }
    }
  }
  cout << "NO";
  return 0;
}
