#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline T min(T a, T b, T c, T d) {
  return min(min(a, b), min(c, d));
}
template <class T>
inline T max(T a, T b, T c, T d) {
  return max(min(a, b), max(c, d));
}
template <class T>
inline T Sqr(T a) {
  return a * a;
}
template <class T>
inline T Cub(T a) {
  return a * a * a;
}
inline void MUL(int &a, int b, int MOD) { a = (long long)a * b % MOD; }
template <class T>
inline T Abs(T a) {
  return a > 0 ? a : -a;
}
inline int PPow(int a, int b, int MOD) {
  int c = 1;
  while (b) {
    if (b & 1) MUL(c, a, MOD);
    MUL(a, a, MOD), b >>= 1;
  }
  return c;
}
int n, k;
char a[2][100010];
bool vis[2][100010];
void dfs(bool x, int y, int Water) {
  if (y > n) {
    cout << "YES" << endl;
    exit(0);
  }
  if (y + k > n) {
    cout << "YES" << endl;
    exit(0);
  }
  vis[x][y] = true;
  if (!vis[1 - x][y + k] && a[1 - x][y + k] != 'X' && Water + 1 < y + k) {
    dfs(1 - x, y + k, Water + 1);
  }
  if (!vis[x][y + 1] && a[x][y + 1] != 'X' && Water + 1 < y + 1) {
    dfs(x, y + 1, Water + 1);
  }
  if (y - 1 >= 1 && !vis[x][y - 1] && a[x][y - 1] != 'X' && Water + 1 < y - 1) {
    dfs(x, y - 1, Water + 1);
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[0][i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[1][i];
  }
  dfs(0, 1, 0);
  cout << "NO" << endl;
  return 0;
}
