#include <bits/stdc++.h>
using namespace std;
int n, k, vis[2][100000], ans = 0;
char a[2][100000];
void dfs(int i, int w, int t) {
  if (i >= n) {
    cout << "c1 " << i << " " << w << " " << t << "\n";
    ans = 1;
    return;
  }
  if (t > i) {
    cout << "ct " << i << " " << w << " " << t << "\n";
    return;
  }
  if (i < 0) {
    cout << "c2 " << i << " " << w << " " << t << "\n";
    return;
  }
  if (a[w][i] == 'X') {
    cout << "c3 " << i << " " << w << " " << t << "\n";
    return;
  }
  if (vis[w][i]) {
    cout << "c4 " << i << " " << w << " " << t << "\n";
    return;
  }
  cout << "c5 " << i << " " << w << " " << t << "\n";
  vis[w][i] = 1;
  dfs(i - 1, w, t + 1);
  dfs(i + 1, w, t + 1);
  dfs(i + k, 1 - w, t + 1);
}
struct type {
  int i;
  int w;
  int t;
};
bool bfs() {
  queue<type> q;
  type t;
  t.i = 0;
  t.w = 0;
  t.t = 0;
  q.push(t);
  while (!q.empty()) {
    t = q.front();
    q.pop();
    if (t.i >= n) {
      ans = 1;
      return true;
    } else if (t.t > t.i)
      continue;
    else if (t.i < 0)
      continue;
    else if (a[t.w][t.i] == 'X')
      continue;
    else if (vis[t.w][t.i])
      continue;
    vis[t.w][t.i] = 1;
    t.i--;
    t.t++;
    q.push(t);
    t.i += 2;
    q.push(t);
    t.i += k - 1;
    t.w = 1 - t.w;
    q.push(t);
  }
  return false;
}
int main() {
  int i;
  cin >> n >> k;
  cin >> a[0] >> a[1];
  bfs();
  if (ans)
    cout << "YES";
  else
    cout << "NO";
}
