#include <bits/stdc++.h>
using namespace std;
char a[200100];
char b[200100];
int n, k;
int visit[200100];
int visit2[200100];
int mn = 0;
int cal(int x, int turn, int up, int lvl) {
  if (lvl >= x) return 0;
  if (x > n) {
    mn = 1;
    return 1;
  }
  if (turn == 1 && x <= 100050) {
    if (visit[x] == 1) return 0;
  } else if (x <= 100050) {
    if (visit2[x] == 1) return 0;
  }
  if (turn == 1 && x <= 100050)
    visit[x] = 1;
  else if (x <= 100050)
    visit2[x] = 1;
  int f1 = 0;
  int f2 = 0;
  int f3 = 0;
  if (turn == 1) {
    if (up == 1) {
      if (b[x + k] != 'X') {
        f2 = cal(x + k, 2, 3, lvl + 1);
      }
      if (a[x + 1] != 'X') {
        f1 = cal(x + 1, 1, 1, lvl + 1);
      }
    } else if (up == 2) {
      if (b[x + k] != 'X') {
        f2 = cal(x + k, 2, 3, lvl + 1);
      }
      if (x - 1 >= 1 && a[x - 1] != 'X') {
        f1 = cal(x - 1, 1, 2, lvl + 1);
      }
    } else {
      if (b[x + k] != 'X') {
        f3 = cal(x + k, 2, 3, lvl + 1);
      }
      if (a[x + 1] != 'X') {
        f1 = cal(x + 1, 1, 1, lvl + 1);
      }
      if (x - 1 >= 1 && a[x - 1] != 'X') {
        f1 = cal(x - 1, 1, 2, lvl + 1);
      }
    }
  } else {
    if (up == 1) {
      if (a[x + k] != 'X') {
        f2 = cal(x + k, 1, 3, lvl + 1);
      }
      if (b[x + 1] != 'X') {
        f1 = cal(x + 1, 2, 1, lvl + 1);
      }
    } else if (up == 2) {
      if (a[x + k] != 'X') {
        f2 = cal(x + k, 1, 3, lvl + 1);
      }
      if (x - 1 >= 1 && b[x - 1] != 'X') {
        f1 = cal(x - 1, 2, 2, lvl + 1);
      }
    } else {
      if (a[x + k] != 'X') {
        f3 = cal(x + k, 1, 3, lvl + 1);
      }
      if (b[x + 1] != 'X') {
        f1 = cal(x + 1, 2, 1, lvl + 1);
      }
      if (x - 1 >= 1 && b[x - 1] != 'X') {
        f1 = cal(x - 1, 2, 2, lvl + 1);
      }
    }
  }
  return (f1 | f2 | f3);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  int ans = cal(1, 1, 3, 0);
  if (mn)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
