#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const int mod = 10007;
const int M = 2 * 1e2 + 5;
const int N = 1e5 + 5;
int n, m;
char s[3][N];
int v[3][N];
bool dfs(int x, int y, int h) {
  if (y > n) return 1;
  if (v[x][y] || s[x][y] == 'X' || y < h) return 0;
  v[x][y] = 1;
  if (dfs(3 - x, y + m, h + 1) | dfs(x, y + 1, h + 1) | dfs(x, y - 1, h + 1))
    return 1;
  return 0;
}
signed main() {
  cin >> n >> m;
  for (int i = 1; i <= 2; i++) scanf("%s", s[i] + 1);
  if (dfs(1, 1, 1))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
