#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, k, flag;
struct wall {
  char left;
  char right;
  int x, y;
} w[maxn];
void dfs(int water, int loc, int fr) {
  if (loc <= water) return;
  if (fr == 0) {
    if (w[loc].x) return;
    if (flag == 0) return;
    if (loc + k == n && w[n].right == '-') {
      flag = 0;
      return;
    }
    if (loc + k > n) {
      flag = 0;
      return;
    }
    w[loc].x = 1;
    if (w[loc + k].right == '-') dfs(water + 1, loc + k, 1);
    if (loc > 1 && w[loc - 1].left == '-') dfs(water + 1, loc - 1, 0);
    if (w[loc + 1].left == '-') dfs(water + 1, loc + 1, 0);
  } else {
    if (w[loc].y) return;
    if (flag == 0) return;
    if (loc + k == n && w[n].left == '-') {
      flag = 0;
      return;
    }
    if (loc + k > n) {
      flag = 0;
      return;
    }
    w[loc].y = 1;
    if (w[loc + k].left == '-') dfs(water + 1, loc + k, 0);
    if (loc > 1 && w[loc - 1].right == '-') dfs(water + 1, loc - 1, 1);
    if (w[loc + 1].right == '-') dfs(water + 1, loc + 1, 1);
  }
  return;
}
int main() {
  while (~scanf("%d%d", &n, &k)) {
    flag = 1;
    for (int i = 1; i <= n; i++) cin >> w[i].left;
    for (int i = 1; i <= n; i++) cin >> w[i].right;
    dfs(0, 1, 0);
    if (flag == 0) {
      printf("YES\n");
      break;
    } else {
      printf("NO\n");
      break;
    }
  }
  return 0;
}
