#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long d[n][2];
  string s[2];
  cin >> s[0] >> s[1];
  for (int i = 0; i < n; ++i) {
    d[i][0] = d[i][1] = INT_MAX;
  }
  d[0][0] = 0;
  queue<pair<long long, long long>> q;
  q.push(make_pair(0, 0));
  pair<long long, long long> source;
  while (!q.empty()) {
    source = q.front();
    q.pop();
    long long curr = source.first;
    long long curr2 = source.second;
    if ((curr + k) >= n) {
      cout << "YES\n";
      return 0;
    }
    if ((curr - 1) >= 0 && s[curr2][curr - 1] == '-' &&
        d[curr - 1][curr2] == INT_MAX && (d[curr][curr2] + 1) <= (curr - 1)) {
      q.push(make_pair(curr - 1, curr2));
      d[curr - 1][curr2] = d[curr][curr2] + 1;
    }
    if ((curr + 1) < n && s[curr2][curr + 1] == '-' &&
        d[curr + 1][curr2] == INT_MAX && (d[curr][curr2] + 1) <= (curr + 1)) {
      q.push(make_pair(curr + 1, curr2));
      d[curr + 1][curr2] = d[curr][curr2] + 1;
    }
    if ((curr + k) < n && s[(curr2 + 1) % 2][curr + k] == '-' &&
        d[curr + k][(curr2 + 1) % 2] == INT_MAX &&
        (d[curr][curr2] + 1) <= (curr + k)) {
      q.push(make_pair(curr + k, (curr2 + 1) % 2));
      d[curr + k][(curr2 + 1) % 2] = d[curr][curr2] + 1;
    }
  }
  cout << "NO\n";
  return 0;
}
