#include <bits/stdc++.h>
using namespace std;
int n, k;
string s[2];
vector<vector<bool> > visited;
void dfs(int wall, int area, int water) {
  if (visited[wall][area] || s[wall][area] != '-' || area < water)
    return;
  else if (area + k >= n) {
    cout << "YES";
    exit(0);
  }
  visited[wall][area] = true;
  dfs((wall + 1) % 2, area + k, water + 1);
  dfs(wall, area + 1, water + 1);
  dfs(wall, max(0, area - 1), water + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  visited.resize(2, vector<bool>(n));
  cin >> s[0] >> s[1];
  dfs(0, 0, 0);
  cout << "NO";
}
