#include <bits/stdc++.h>
using namespace std;
vector<string> s;
vector<vector<int> > dp;
long long n, k;
bool cal(int str, int ind) {
  queue<pair<int, int> > q;
  q.push({0, 0});
  int water = 0;
  while (q.size()) {
    int len = q.size();
    while (len--) {
      str = q.front().first;
      ind = q.front().second;
      q.pop();
      if (ind + k >= n) return true;
      if (ind < water) {
        continue;
      }
      if (dp[str][ind]) continue;
      dp[str][ind] = 1;
      if ((ind + 1 < n) && ((s[str][ind + 1] == '-'))) q.push({str, ind + 1});
      if (ind - 1 >= 0 && s[str][ind - 1] == '-') q.push({str, ind - 1});
      if (ind + k < n && s[(str == 1) ? 0 : 1][ind + k] == '-')
        q.push({((str == 1) ? 0 : 1), ind + k});
    }
    ++water;
  }
  return false;
}
int main() {
  cin >> n >> k;
  s.resize(2);
  cin >> s[0] >> s[1];
  dp.resize(2, (vector<int>(n, 0)));
  if (cal(0, 0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
