#include <bits/stdc++.h>
using namespace std;
char a[5][100005];
queue<pair<int, int> > que;
int n, k, water[5][100005];
int main() {
  cin >> n >> k;
  getchar();
  for (int t = 1; t <= 2; t++)
    for (int i = 1; i <= n; i++) cin >> a[t][i];
  que.push(make_pair(1, 1));
  water[1][1] = 1;
  while (!que.empty()) {
    int x = que.front().first;
    int y = que.front().second;
    que.pop();
    if (y + 1 > n || y + k > n) {
      cout << "YES";
      return 0;
    }
    if (a[x][y + 1] == '-' && !water[x][y + 1]) {
      que.push(make_pair(x, y + 1));
      water[x][y + 1] = water[x][y] + 1;
    }
    if (a[3 - x][y + k] == '-' && !water[3 - x][y + k]) {
      que.push(make_pair(3 - x, y + k));
      water[3 - x][y + k] = water[x][y] + 1;
    }
    if (a[x][y - 1] == '-' && y - 1 > water[x][y] && !water[x][y - 1]) {
      que.push(make_pair(x, y - 1));
      water[x][y - 1] = water[x][y] + 1;
    }
  }
  cout << "NO";
  return 0;
}
