#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795;
const long double eps = 1e-9;
string l, r;
vector<int> v[200005];
bool visit[200005];
set<pair<int, int> > s;
int main() {
  int n, k, i;
  cin >> n >> k;
  cin >> l >> r;
  for (i = 0; i < l.length() - 1; i++) {
    if (l[i] == '-' && l[i + 1] == '-') {
      v[i].push_back((i + 1));
      v[i + 1].push_back((i));
    }
    if (r[i] == '-' && r[i + 1] == '-') {
      v[n + i].push_back((n + i + 1));
      v[n + i + 1].push_back(n + i);
    }
    if (i + k < n) {
      if (l[i] == '-' && r[i + k] == '-') {
        v[i].push_back(n + i + k);
      }
      if (r[i] == '-' && l[i + k] == '-') {
        v[n + i].push_back(i + k);
      }
    }
  }
  s.insert(make_pair(0, 0));
  while (!s.empty()) {
    int node = s.begin()->first;
    int water = s.begin()->second;
    visit[node] = true;
    if (node < n) {
      if (node + k >= n) {
        cout << "YES" << endl;
        return 0;
      }
    }
    if (node >= n) {
      if (node + k >= (2 * n)) {
        cout << "YES" << endl;
        return 0;
      }
    }
    s.erase(s.begin());
    for (int i = 0; i < v[node].size(); i++) {
      if (visit[v[node][i]] == false) {
        if (v[node][i] >= n) {
          if ((v[node][i] - n) > water)
            s.insert(make_pair(v[node][i], water + 1));
        }
        if (v[node][i] < n) {
          if (v[node][i] > water) s.insert(make_pair(v[node][i], water + 1));
        }
      }
    }
  }
  cout << "NO";
  return 0;
}
