#include <bits/stdc++.h>
using namespace std;
string L, R;
int dis[100005][2], n, k;
queue<pair<int, int> > q;
int main() {
  cin >> n >> k;
  cin >> L >> R;
  for (int i = 0; i < n; i++) {
    dis[i][0] = dis[i][1] = INT_MAX;
  }
  dis[0][0] = 0;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    pair<int, int> x = q.front();
    q.pop();
    int ndis = dis[x.first][x.second];
    if (x.first + k >= n) {
      cout << "YES\n";
      return 0;
    }
    if ((x.second == 0 && L[x.first + 1] == '-') ||
        (x.second == 1 && R[x.first + 1] == '-')) {
      if (dis[x.first + 1][x.second] == INT_MAX) {
        dis[x.first + 1][x.second] = ndis + 1;
        q.push(make_pair(x.first + 1, x.second));
      }
    }
    if (x.first - 1 >= ndis + 1) {
      if ((x.second == 0 && L[x.first - 1] == '-') ||
          (x.second == 1 && R[x.first - 1] == '-')) {
        if (dis[x.first - 1][x.second] == INT_MAX) {
          dis[x.first - 1][x.second] = ndis + 1;
          q.push(make_pair(x.first - 1, x.second));
        }
      }
    }
    if ((x.second == 0 && R[x.first + k] == '-') ||
        (x.second == 1 && L[x.first + k] == '-')) {
      if (dis[x.first + k][1 - x.second] == INT_MAX) {
        dis[x.first + k][1 - x.second] = ndis + 1;
        q.push(make_pair(x.first + k, 1 - x.second));
      }
    }
  }
  cout << "NO\n";
  return 0;
}
