#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[3][n + 1];
  for (int i = 1; i <= 2; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == '-') {
        a[i][j + 1] = 1;
      } else {
        a[i][j + 1] = 0;
      }
    }
  }
  queue<pair<int, pair<int, int>>> q;
  q.push({1, {1, 0}});
  vector<vector<int>> vis(3, vector<int>(n + 1, 0));
  vis[1][1] = 1;
  int flag = 0;
  while (!q.empty()) {
    pair<int, pair<int, int>> p = q.front();
    q.pop();
    if (p.second.first >= n || p.second.first + 1 > n ||
        p.second.first + k > n) {
      flag = 1;
      break;
    }
    if (p.second.first + 1 > p.second.second + 1 &&
        a[p.first][p.second.first + 1] == 1 &&
        vis[p.first][p.second.first + 1] == 0) {
      vis[p.first][p.second.first + 1] = 1;
      q.push({p.first, {p.second.first + 1, p.second.second + 1}});
    }
    if (p.second.first - 1 >= 1)
      if (p.second.first - 1 > p.second.second + 1 &&
          a[p.first][p.second.first - 1] == 1 &&
          vis[p.first][p.second.first - 1] == 0) {
        vis[p.first][p.second.first - 1] = 1;
        q.push({p.first, {p.second.first - 1, p.second.second + 1}});
      }
    int jump = p.first == 1 ? 2 : 1;
    if (p.second.first + k > p.second.second + 1 &&
        a[jump][p.second.first + k] == 1 &&
        vis[jump][p.second.first + k] == 0) {
      vis[jump][p.second.first + k] = 1;
      q.push({jump, {p.second.first + k, p.second.second + 1}});
    }
  }
  if (flag == 1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
