#include <bits/stdc++.h>
using namespace std;
int n, K;
int distLimit[300001];
vector<int> e[300001];
int dist[300001];
string A, B;
int leftSide(int x) { return x; }
int rightSide(int x) { return x + n; }
void addEdge(int a, int b) {
  e[a].push_back(b);
  e[b].push_back(a);
}
int Q[1000001], now, z;
void BFS() {
  Q[0] = 0;
  now = z = 0;
  while (now <= z) {
    int s = Q[now];
    for (int i = 0; i < (int)e[s].size(); i++) {
      int t = e[s][i];
      if (dist[t] > dist[s] + 1)
        if (dist[s] + 1 <= distLimit[t]) {
          dist[t] = dist[s] + 1;
          Q[++z] = t;
        }
    }
    ++now;
  }
}
int MAIN() {
  while (cin >> n >> K >> A >> B) {
    for (int i = 0; i < 2 * n; i++) {
      e[i].clear();
      distLimit[i] = i % n;
    }
    for (int i = 0; i < n; i++)
      if (A[i] == '-') {
        if (i > 0 && A[i - 1] == '-') addEdge(leftSide(i), leftSide(i - 1));
        if (i + 1 < n && A[i + 1] == '-') addEdge(leftSide(i), leftSide(i + 1));
        if (i + K < n && B[i + K] == '-')
          addEdge(leftSide(i), rightSide(i + K));
      }
    for (int i = 0; i < n; i++)
      if (B[i] == '-') {
        if (i > 0 && B[i - 1] == '-') addEdge(rightSide(i), rightSide(i - 1));
        if (i + 1 < n && B[i + 1] == '-')
          addEdge(rightSide(i), rightSide(i + 1));
        if (i + K < n && A[i + K] == '-')
          addEdge(rightSide(i), leftSide(i + K));
      }
    memset(dist, 0xe, sizeof(dist));
    dist[leftSide(0)] = 0;
    BFS();
    bool find = false;
    for (int i = 0; i < n; i++)
      if (i + K >= n) {
        if (dist[leftSide(i)] <= n) find = true;
        if (dist[rightSide(i)] <= n) find = true;
      }
    if (find)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  int RUN_RESULT = MAIN();
  return RUN_RESULT;
}
