#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
void debugarr(int* arr, int n) {
  cout << "[";
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
void debugvec(vector<int> arr) {
  cout << "[";
  for (int i = 0; i < ((int)(arr.size())); i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
bool wall[2][100005];
bool done[2][100005];
int level[2][100005];
int n, k;
bool found = false;
void bfs() {
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  done[0][0] = true;
  level[0][0] = -1;
  while (!q.empty()) {
    pair<int, int> u = q.front();
    q.pop();
    done[u.first][u.second] = true;
    int i = u.first, j = u.second;
    if (j + k >= n) {
      found = true;
      break;
    }
    if (j > 0 && wall[i][j - 1] && !done[i][j - 1] &&
        (j - 1) > level[i][j] + 1) {
      if (level[i][j - 1] > level[i][j] + 1) {
        q.push(make_pair(i, j - 1));
        level[i][j - 1] = level[i][j] + 1;
      }
    }
    if (wall[i][j + 1] && !done[i][j + 1]) {
      if (level[i][j + 1] > level[i][j] + 1) {
        q.push(make_pair(i, j + 1));
        level[i][j + 1] = level[i][j] + 1;
      }
    }
    if (wall[i ^ 1][j + k] && !done[i ^ 1][j + k]) {
      if (level[i ^ 1][j + k] > level[i][j] + 1) {
        q.push(make_pair(i ^ 1, j + k));
        level[i ^ 1][j + k] = level[i][j] + 1;
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  memset(done, false, sizeof(done));
  for (int i = 0; i < 100005; i++) {
    level[0][i] = INT_MAX;
    level[1][i] = INT_MAX;
  }
  memset(wall, false, sizeof(wall));
  string str;
  cin >> str;
  for (int i = 0; i < n; i++) {
    if (str[i] == '-') wall[0][i] = true;
  }
  cin >> str;
  for (int i = 0; i < n; i++) {
    if (str[i] == '-') wall[1][i] = true;
  }
  bfs();
  if (found)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
