#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  string s1, s2;
  cin >> s1 >> s2;
  long long i, j;
  i = n - 1;
  long long c = 0LL;
  long long f = 0LL;
  char mat[2][n];
  for (i = 0; i < 2; i++) {
    for (j = 0; j < n; j++) {
      if (i == 0) {
        mat[0][j] = s1[i];
      } else {
        mat[1][j] = s2[j];
      }
    }
  }
  char fin[2][n];
  for (i = 0; i < 2; i++) {
    for (j = 0; j < n; j++) {
      fin[i][j] = 'F';
    }
  }
  queue<pair<long long, pair<long long, long long>>> q;
  q.push({0, {0, 0}});
  fin[0][0] = 'T';
  while (q.size() > 0) {
    long long level;
    long long f1;
    level = q.front().first;
    f1 = q.front().second.first;
    i = q.front().second.second;
    q.pop();
    level++;
    if (f1 == 0) {
      if (i - 1 >= 0 && i - 1 >= level && s1[i - 1] == '-' &&
          fin[0][i - 1] == 'F') {
        q.push({level, {0, i - 1}});
        fin[0][i - 1] = 'T';
      }
      if (i + 1 >= n) {
        cout << "YES";
        return 0;
      }
      if (i + 1 < n && i + 1 >= level && s1[i + 1] == '-' &&
          fin[0][i + 1] == 'F') {
        q.push({level, {0, i + 1}});
        fin[0][i + 1] = 'T';
      }
      if (i + k >= n) {
        cout << "YES";
        return 0;
      }
      if (i + k >= level && s2[i + k] == '-' && fin[1][i + k] == 'F') {
        q.push({level, {1, i + k}});
        fin[1][i + k] = 'T';
      }
      if (i - k >= 0 && i - k >= level && s2[i - k] == '-' &&
          fin[1][i - k] == 'F') {
        q.push({level, {1, i - k}});
        fin[1][i - k] = 'T';
      }
    } else {
      if (i - 1 >= 0 && i - 1 >= level && s2[i - 1] == '-' &&
          fin[1][i - 1] == 'F') {
        q.push({level, {1, i - 1}});
        fin[1][i - 1] = 'T';
      }
      if (i + 1 >= n) {
        cout << "YES";
        return 0;
      }
      if (i + 1 < n && i + 1 >= level && s2[i + 1] == '-' &&
          fin[1][i + 1] == 'F') {
        q.push({level, {1, i + 1}});
        fin[1][i + 1] = 'T';
      }
      if (i + k >= n) {
        cout << "YES";
        return 0;
      }
      if (i + k >= level && s1[i + k] == '-' && fin[0][i + k] == 'F') {
        q.push({level, {0, i + k}});
        fin[0][i + k] = 'T';
      }
      if (i - k >= 0 && i - k >= level && s1[i - k] == '-' &&
          fin[0][i - k] == 'F') {
        q.push({level, {1, i - k}});
        fin[0][i - k] = 'T';
      }
    }
  }
  cout << "NO";
  return 0;
}
