#include <bits/stdc++.h>
using namespace std;
string L, R;
int dist[2][100010];
queue<int> q;
int main(void) {
  int N, K, i, j;
  cin >> N >> K;
  cin >> L >> R;
  for ((i) = 0; (i) < (int)(2); (i)++)
    for ((j) = 0; (j) < (int)(N); (j)++) dist[i][j] = (1 << 29);
  dist[0][0] = 0;
  q.push(0);
  q.push(0);
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    int h = q.front();
    q.pop();
    int t = dist[s][h];
    if (h + K >= N) {
      cout << "YES" << endl;
      return 0;
    }
    if ((s == 0 && L[h + 1] == '-') || (s == 1 && R[h + 1] == '-'))
      if (dist[s][h + 1] == (1 << 29)) {
        dist[s][h + 1] = t + 1;
        q.push(s);
        q.push(h + 1);
      }
    if (h - 1 >= t + 1)
      if ((s == 0 && L[h - 1] == '-') || (s == 1 && R[h - 1] == '-'))
        if (dist[s][h - 1] == (1 << 29)) {
          dist[s][h - 1] = t + 1;
          q.push(s);
          q.push(h - 1);
        }
    if ((s == 0 && R[h + K] == '-') || (s == 1 && L[h + K] == '-'))
      if (dist[1 - s][h + K] == (1 << 29)) {
        dist[1 - s][h + K] = t + 1;
        q.push(1 - s);
        q.push(h + K);
      }
  }
  cout << "NO" << endl;
  return 0;
}
