#include <bits/stdc++.h>
using namespace std;
int N, K;
char A[3][100005];
queue<pair<int, int> > qu;
int H[2][100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  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];
  A[0][0] = 'X';
  A[1][0] = 'X';
  memset(H, 1, sizeof(H));
  H[0][1] = 0;
  qu.push(pair<int, int>(0, 1));
  while (qu.size()) {
    int w = qu.front().first;
    int i = qu.front().second;
    qu.pop();
    if (H[w][i] >= i) continue;
    if (A[1 - w][i + K] != 'X')
      if (H[1 - w][i + K] > H[w][i] + 1) {
        H[1 - w][i + K] = H[w][i] + 1;
        qu.push(pair<int, int>(1 - w, i + K));
      }
    if (A[w][i + 1] != 'X')
      if (H[w][i + 1] > H[w][i] + 1) {
        H[w][i + 1] = H[w][i] + 1;
        qu.push(pair<int, int>(w, i + 1));
      }
    if (A[w][i - 1] != 'X')
      if (H[w][i - 1] > H[w][i] + 1) {
        H[w][i - 1] = H[w][i] + 1;
        qu.push(pair<int, int>(w, i - 1));
      }
    if (i + 1 > N || i + K > N) {
      cout << "YES";
      exit(0);
    }
  }
  cout << "NO";
  return 0;
}
