#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > que;
bool flag = false;
int b[2][100005];
bool safe[2][100005];
int n, k;
void bfs(const int &x, const int &y) {
  if (y + k >= n) {
    flag = true;
    return;
  }
  if (y - 1 > b[x][y] && safe[x][y - 1] && b[x][y - 1] == -1) {
    b[x][y - 1] = b[x][y] + 1;
    que.push(make_pair(x, y - 1));
  }
  if (safe[x][y + 1] && b[x][y + 1] == -1) {
    b[x][y + 1] = b[x][y] + 1;
    que.push(make_pair(x, y + 1));
  }
  if (safe[x ^ 1][y + k] && b[x ^ 1][y + k] == -1) {
    b[x ^ 1][y + k] = b[x][y] + 1;
    que.push(make_pair(x ^ 1, y + k));
  }
}
int main() {
  cin >> n >> k;
  string str;
  cin >> str;
  for (int i = 0; i < n; ++i) safe[0][i] = str[i] == '-';
  cin >> str;
  for (int i = 0; i < n; ++i) safe[1][i] = str[i] == '-';
  memset(b, -1, sizeof(b));
  que.push(make_pair(0, 0));
  b[0][0] = 0;
  while (!que.empty()) {
    bfs(que.front().first, que.front().second);
    que.pop();
    if (flag) break;
  }
  if (flag)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
