#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
const double eps = 1e-7;
int dp[200002][2];
int k, b, n, ans = 0, t;
string s0, s1;
void rec(int lev, int st, int val) {
  if (val >= lev) return;
  if (lev >= n) {
    puts("YES");
    exit(0);
  }
  if (dp[lev][st] <= val) return;
  dp[lev][st] = val;
  if (st == 0) {
    if (lev + k >= n || s1[lev + k] == '-') rec(lev + k, 1 - st, val + 1);
    if (s0[lev + 1] == '-') rec(lev + 1, st, val + 1);
    if (lev && s0[lev - 1] == '-') rec(lev - 1, st, val + 1);
  } else {
    if (lev + k >= n || s0[lev + k] == '-') rec(lev + k, 1 - st, val + 1);
    if (s1[lev + 1] == '-') rec(lev + 1, st, val + 1);
    if (lev && s1[lev - 1] == '-') rec(lev - 1, st, val + 1);
  }
}
int main() {
  cin >> n >> k;
  cin >> s0 >> s1;
  s0.push_back('-');
  s1.push_back('-');
  for (int(i) = 0; (i) < (200002); ++(i)) dp[i][0] = dp[i][1] = INF;
  rec(0, 0, -1);
  puts("NO");
  return 0;
}
