#include <bits/stdc++.h>
using namespace std;
int n, k;
string str[2];
int dist[2][100005];
int main() {
  cin >> n >> k >> str[0] >> str[1];
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  memset(dist, -1, sizeof(dist));
  dist[0][0] = 0;
  while (!q.empty()) {
    int s = q.front().first, h = q.front().second, t = dist[s][h];
    q.pop();
    if (h + k >= n) {
      puts("YES");
      return 0;
    }
    if (str[s][h + 1] == '-' && dist[s][h + 1] == -1) {
      dist[s][h + 1] = t + 1;
      q.push(make_pair(s, h + 1));
    }
    if (str[s][h - 1] == '-' && h - 1 >= t + 1 && dist[s][h - 1] == -1) {
      dist[s][h - 1] = t + 1;
      q.push(make_pair(s, h - 1));
    }
    if (str[s ^ 1][h + k] == '-' && dist[s ^ 1][h + k] == -1) {
      dist[s ^ 1][h + k] = t + 1;
      q.push(make_pair(s ^ 1, h + k));
    }
  }
  puts("NO");
  return 0;
}
