#include <bits/stdc++.h>
using namespace std;
queue<int> q;
int d[2][100005], n, k;
char A[2][100005];
void f(int w, int h, int val) {
  if (h + 1 < n && A[w][h + 1] == '-' && d[w][h + 1] == 0x3f3f3f3f)
    q.push(w), q.push(h + 1), d[w][h + 1] = val + 1;
  if (h - 1 >= 0 && A[w][h - 1] == '-' && d[w][h - 1] == 0x3f3f3f3f &&
      val < h - 1)
    q.push(w), q.push(h - 1), d[w][h - 1] = val + 1;
  if (h + k < n && A[1 - w][h + k] == '-' && d[1 - w][h + k] == 0x3f3f3f3f)
    q.push(1 - w), q.push(h + k), d[1 - w][h + k] = val + 1;
}
int main() {
  int i, j;
  scanf("%d %d %s %s", &n, &k, &A[0], &A[1]);
  memset(d, 63, sizeof(d));
  q.push(0);
  q.push(0);
  d[0][0] = 0;
  while (!q.empty()) {
    i = q.front();
    q.pop();
    j = q.front();
    q.pop();
    f(i, j, d[i][j]);
  }
  bool ok = false;
  for (i = 0; i < 2; i++)
    for (j = 0; j < n; j++)
      if (j + k >= n && A[i][j] == '-' && d[i][j] <= j) ok = true;
  if (ok)
    puts("YES");
  else
    puts("NO");
  return 0;
}
