#include <bits/stdc++.h>
using namespace std;
const int MaxN = 300005;
int a[MaxN][4];
bool mark[MaxN][4];
int n, k;
int x[MaxN * 5], y[MaxN * 5];
char s[MaxN];
bool good(int x, int y) { return 1 <= x && 1 <= y && y <= 2; }
int main() {
  scanf("%d%d", &n, &k);
  int di[] = {1, -1, k, k};
  int dj[] = {0, 0, 1, -1};
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= 2; i++) {
    scanf("%s", s);
    for (int j = 0; j < n; j++) {
      a[j + 1][i] = ('X' == s[j]);
    }
  }
  memset(mark, false, sizeof(mark));
  int i = 1, j = 1;
  x[1] = 1;
  y[1] = 1;
  int move = 1;
  while (i <= j) {
    int z = j;
    for (int q = i; q <= j; q++)
      for (int dir = 0; dir < 4; dir++) {
        int ni = x[q] + di[dir];
        int nj = y[q] + dj[dir];
        if (good(ni, nj) && !mark[ni][nj] && !a[ni][nj] && ni > move) {
          mark[ni][nj] = true;
          z++;
          x[z] = ni;
          y[z] = nj;
          if (ni > n) {
            printf("YES\n");
            return 0;
          }
        }
      }
    move++;
    i = j + 1;
    j = z;
  }
  printf("NO\n");
  return 0;
}
