#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, z;
};
node q[200001];
int n, m;
bool ok[2][100001];
char s[100005];
int main(void) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < 2; ++i) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; ++j)
      if (s[j] == '-') ok[i][j] = true;
  }
  bool flag = false;
  q[1].x = 0;
  q[1].y = 1;
  q[1].z = 0;
  int h = 1, e = 1;
  ok[0][1] = false;
  while (h <= e) {
    node p = q[h];
    ++h;
    int i = p.x, j = p.y, k = p.z;
    if (j <= k) continue;
    if ((j + 1 > n) || (j + m > n)) {
      flag = true;
      break;
    }
    if (ok[i][j + 1]) {
      ++e;
      q[e].x = i;
      q[e].y = j + 1;
      q[e].z = k + 1;
      ok[i][j + 1] = false;
    }
    if (ok[i ^ 1][j + m]) {
      ++e;
      q[e].x = i ^ 1;
      q[e].y = j + m;
      q[e].z = k + 1;
      ok[i ^ 1][j + m] = false;
    }
    if (ok[i][j - 1]) {
      ++e;
      q[e].x = i;
      q[e].y = j - 1;
      q[e].z = k + 1;
      ok[i][j - 1] = false;
    }
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
