#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long MAX = 1e5 + 5;
const long long MAX2 = 11;
const int MOD = 1000000000 + 7;
const long long INF = 1e18;
const int nr[] = {1, 0, 0, -1, 1, 1, -1, -1};
const int nc[] = {0, 1, -1, 0, 1, -1, 1, -1};
int n, k, nx, lr, nw, vis[2][MAX];
char x[2][MAX];
queue<pair<bool, int> > q;
bool ans;
pair<bool, int> cur;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long j = 0; j <= 1; j++)
    for (long long i = 1; i <= n; i++) cin >> x[j][i];
  memset(vis, -1, sizeof vis);
  q.push({0, 1});
  vis[0][1] = 1;
  while (!q.empty()) {
    cur = q.front();
    q.pop();
    lr = cur.first, nw = cur.second;
    if (nw + k > n) {
      ans = 1;
      break;
    }
    for (long long i = 1; i <= 2; i++) {
      nx = nw + nc[i];
      if (x[lr][nx] == '-' && vis[lr][nx] == -1 && nx > vis[lr][nw]) {
        vis[lr][nx] = vis[lr][nw] + 1;
        q.push({lr, nx});
      }
    }
    if (x[lr ^ 1][nw + k] == '-' && vis[lr ^ 1][nw + k] == -1) {
      vis[lr ^ 1][nw + k] = vis[lr][nw] + 1;
      q.push({lr ^ 1, nw + k});
    }
  }
  if (ans)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
