#include <bits/stdc++.h>
const double pi = acos(-1.0), eps = 1e-9;
const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const int MO = (int)(1e9 + 7);
using namespace std;
bool vis[3][2000001];
int time1[3][2000001];
char s[3][2000001];
int n, k;
queue<pair<int, int> > Q;
void bfs(int x, int y) {
  Q.push(make_pair(x, y));
  vis[x][y] = true;
  while (!Q.empty()) {
    pair<int, int> now = Q.front();
    int x = now.first, y = now.second, nt = ::time1[x][y];
    Q.pop();
    if (y > 1 && nt + 1 < y - 1 && !vis[x][y - 1] && s[x][y - 1] == '-') {
      time1[x][y - 1] = time1[x][y] + 1;
      vis[x][y - 1] = true;
      Q.push(make_pair(x, y - 1));
    }
    if (y < n && nt + 1 < y + 1 && !vis[x][y + 1] && s[x][y + 1] == '-') {
      time1[x][y + 1] = time1[x][y] + 1;
      vis[x][y + 1] = true;
      Q.push(make_pair(x, y + 1));
    }
    if (y + k <= n && nt + 1 < y + k && !vis[x % 2 + 1][y + k] &&
        s[x % 2 + 1][y + k] == '-') {
      time1[x % 2 + 1][y + k] = time1[x][y] + 1;
      vis[x % 2 + 1][y + k] = true;
      Q.push(make_pair(x % 2 + 1, y + k));
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  scanf(" ");
  gets(s[1] + 1);
  gets(s[2] + 1);
  bfs(1, 1);
  bool ok = false;
  for (int i = 1; i <= 2; i++)
    for (int j = 1; j <= n; j++)
      if (vis[i][j] && j + k > n) ok = true;
  puts(ok ? "YES" : "NO");
}
