#include <bits/stdc++.h>
using namespace std;
struct data {
  int X, v, l;
  data() {}
  data(int xx, int vv, int ll) { X = xx, v = vv, l = ll; }
};
string G[2];
int n, k, visited[2][100008];
string bfs() {
  queue<data> Q;
  Q.push(data(0, 0, -1));
  visited[0][0] = 1;
  int v, dir, l;
  data top;
  while (!Q.empty()) {
    top = Q.front();
    Q.pop();
    if (top.v == n) return "YES";
    v = top.v + 1, dir = top.X, l = top.l + 1;
    if (v <= n && G[dir][v] == '-' && !visited[dir][v] && v > l) {
      visited[dir][v] = 1;
      Q.push(data(dir, v, l));
    }
    v = top.v - 1, dir = top.X, l = top.l + 1;
    if (v >= 0 && G[dir][v] == '-' && !visited[dir][v] && v > l) {
      visited[dir][v] = 1;
      Q.push(data(dir, v, l));
    }
    v = min(top.v + k, n), dir = top.X ^ 1, l = top.l + 1;
    if (v <= n && G[dir][v] == '-' && !visited[dir][v] && v > l) {
      visited[dir][v] = 1;
      Q.push(data(dir, v, l));
    }
  }
  return "NO";
}
int main() {
  cin >> n >> k;
  cin >> G[0] >> G[1];
  G[0].push_back('-');
  G[1].push_back('-');
  cout << bfs() << endl;
  return 0;
}
