#include <bits/stdc++.h>
using namespace std;
int shuiwei, n, k, flag;
char mp[2][1000005];
int vis[2][1000005];
int dfs(int shu, int heng) {
  if (heng > n) return 1;
  if (heng < shuiwei || vis[shu][heng] || mp[shu][heng] == 'X') return 0;
  vis[shu][heng] = 1;
  shuiwei++;
  flag = dfs(shu, heng - 1) || dfs(1 - shu, heng + k) || dfs(shu, heng + 1);
  shuiwei--;
  return flag;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (cin >> n >> k) {
    shuiwei = 1;
    for (int i = 0; i < 2; i++)
      for (int j = 1; j <= n; j++) {
        cin >> mp[i][j];
      }
    if (dfs(0, 1))
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
}
