#include <bits/stdc++.h>
using namespace std;
char wall[3][100005];
int N, K, visited[3][100005], d[3][100005];
int moveX[3][3], moveY[3][3], flag = 0;
void bfs() {
  queue<pair<int, int>> Q;
  Q.push(make_pair(1, 1));
  visited[1][1] = 1;
  d[1][1] = 0;
  while (!Q.empty()) {
    pair<int, int> p = Q.front();
    Q.pop();
    int x = p.first, y = p.second;
    for (int i = 0; i < 3; i++) {
      int xn = x + moveX[x][i];
      int yn = y + moveY[x][i];
      if (!visited[xn][yn]) {
        if (yn > N)
          flag = 1;
        else {
          if (d[x][y] + 1 < yn && wall[xn][yn] == '-') {
            Q.push(make_pair(xn, yn));
            visited[xn][yn] = 1;
            d[xn][yn] = d[x][y] + 1;
          }
        }
      }
    }
  }
}
int main() {
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> wall[1][i];
  for (int i = 1; i <= N; i++) cin >> wall[2][i];
  moveX[1][0] = 1;
  moveX[1][1] = 0;
  moveX[1][2] = 0;
  moveY[1][0] = K;
  moveY[1][1] = 1;
  moveY[1][2] = -1;
  moveX[2][0] = -1;
  moveX[2][1] = 0;
  moveX[2][2] = 0;
  moveY[2][0] = K;
  moveY[2][1] = 1;
  moveY[2][2] = -1;
  memset(d, 100000000, sizeof(d));
  bfs();
  if (flag == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
