#include <bits/stdc++.h>
using namespace std;
void print(char* A, char* B, int h) {
  for (int i = 0; i < h; i++) {
    cout << A[i];
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << B[i];
  }
}
bool backtrack(int pos, char* A, char* B, int h, int jump, int water) {
  if (pos < h) {
    if (pos < water) return false;
    water++;
    if (pos < 0) return false;
    if (A[pos] != 'X') {
      A[pos] = 'X';
      if (pos + jump >= h) return true;
      return backtrack(pos - 1, A, B, h, jump, water) ||
             backtrack(pos + jump, B, A, h, jump, water) ||
             backtrack(pos + 1, A, B, h, jump, water);
    } else {
      return false;
    }
  }
  return true;
}
int main() {
  int h, j;
  cin >> h >> j;
  char A[h], B[h];
  for (int i = 0; i < h; i++) cin >> A[i];
  for (int i = 0; i < h; i++) cin >> B[i];
  bool result = backtrack(0, A, B, h, j, 0);
  if (result)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
