#include <bits/stdc++.h>
using namespace std;
int n, k, cnt;
vector<string> s(2);
vector<vector<bool>> a(2, vector<bool>(1e6));
void dfs(int x, int y) {
  if (s[x][y] != '-' || a[x][y] || y < cnt) return;
  if (y + k >= n) {
    cout << "YES";
    exit(0);
  }
  cnt++;
  a[x][y] = 1;
  dfs(1 - x, y + k);
  dfs(x, y + 1);
  dfs(x, y - 1);
  cnt--;
}
int main() {
  cin >> n >> k >> s[0] >> s[1];
  dfs(0, 0);
  cout << "NO";
}
