#include <bits/stdc++.h>
using namespace std;
bool seen[200005];
struct data {
  int node, h, water;
  data(int a, int b, int c) : node(a), h(b), water(c) {}
};
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  string left_wall, right_wall;
  cin >> left_wall >> right_wall;
  vector<vector<pair<int, int> > > G(2 * n + 1);
  int free = 2 * n;
  for (int i = 0; i < n; ++i) {
    int nb = i + k;
    if (left_wall[i] == '-') {
      if (nb < n && right_wall[nb] == '-')
        G[2 * i].push_back(make_pair(2 * nb + 1, k));
      if (nb >= n) G[2 * i].push_back(make_pair(free, k));
      if (i > 0 && left_wall[i - 1] == '-') {
        G[2 * i].push_back(make_pair(2 * i - 2, -1));
        G[2 * i - 2].push_back(make_pair(2 * i, 1));
      }
    }
    if (right_wall[i] == '-') {
      if (nb < n && left_wall[nb] == '-')
        G[2 * i + 1].push_back(make_pair(2 * nb, k));
      if (nb >= n) G[2 * i + 1].push_back(make_pair(free, k));
      if (i > 0 && right_wall[i - 1] == '-') {
        G[2 * i + 1].push_back(make_pair(2 * i - 1, -1));
        G[2 * i - 1].push_back(make_pair(2 * i + 1, 1));
      }
    }
  }
  if (left_wall[n - 1] == '-') G[2 * n - 2].push_back(make_pair(free, k));
  if (right_wall[n - 1] == '-') G[2 * n - 1].push_back(make_pair(free, k));
  memset(seen, 0, sizeof seen);
  seen[0] = 1;
  queue<data> q;
  q.push(data(0, 0, 0));
  while (!q.empty()) {
    data u = q.front();
    q.pop();
    for (int i = 0; i < G[u.node].size(); ++i) {
      int v = G[u.node][i].first, w = G[u.node][i].second;
      if (!seen[v]) {
        seen[v] = true;
        if (u.h + w <= u.water) continue;
        if (u.h + w >= n) {
          cout << "YES";
          return 0;
        }
        q.push(data(v, u.h + w, u.water + 1));
      }
    }
  }
  cout << "NO";
}
