#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
string l, r;
int dist[2][100010];
queue<int> q;
int main(void) {
  int n, k;
  cin >> n >> k >> l >> r;
  for (int i = 0; i < (int)2; i++)
    for (int j = 0; j < (int)n; j++) dist[i][j] = INF;
  dist[0][0] = 0;
  q.push(0);
  q.push(0);
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    int h = q.front();
    q.pop();
    int t = dist[s][h];
    if (h + k >= n) {
      cout << "YES\n";
      return 0;
    }
    if ((s == 0 && l[h + 1] == '-') || (s == 1 && r[h + 1] == '-'))
      if (dist[s][h + 1] == INF) {
        dist[s][h + 1] = t + 1;
        q.push(s);
        q.push(h + 1);
      }
    if (h - 1 >= t + 1)
      if ((s == 0 && l[h - 1] == '-') || (s == 1 && r[h - 1] == '-'))
        if (dist[s][h - 1] == INF) {
          dist[s][h - 1] = t + 1;
          q.push(s);
          q.push(h - 1);
        }
    if ((s == 0 && r[h + k] == '-') || (s == 1 && l[h + k] == '-'))
      if (dist[1 - s][h + k] == INF) {
        dist[1 - s][h + k] = t + 1;
        q.push(1 - s);
        q.push(h + k);
      }
  }
  cout << "NO\n";
  return 0;
}
