#include <bits/stdc++.h>
using namespace std;
int n, k;
char arr[2][100009];
bool solve(int wall, int h, int water) {
  if (arr[wall][h] != '-' || h < 0 || water > h) return false;
  if (h + k >= n) return true;
  arr[wall][h] = 'X';
  if (solve(1 - wall, h + k, water + 1) || solve(wall, h + 1, water + 1) ||
      solve(wall, h - 1, water + 1))
    return true;
  return false;
}
int main() {
  cin >> n >> k;
  cin >> arr[0] >> arr[1];
  cout << (solve(0, 0, 0) == true ? "YES" : "NO");
}
