#include <bits/stdc++.h>
using namespace std;
int n, m, d[2][1000000];
bool ans, vis[2][1000000];
void dfs(int j, int i, int water) {
  if (water >= i) {
    return;
  }
  if (i >= n) {
    ans = 1;
    return;
  }
  vis[j][i] = 1;
  if (d[j][i - 1] != 0 && vis[j][i - 1] == 0) dfs(j, i - 1, water + 1);
  if (i + m >= n || (d[1 - j][i + m] != 0 && vis[1 - j][i + m] == 0))
    dfs(1 - j, i + m, water + 1);
  if (i + 1 >= n || (d[j][i + 1] != 0 && vis[j][i + 1] == 0))
    dfs(j, i + 1, water + 1);
  return;
}
int main() {
  char z;
  cin >> n >> m;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < n; j++) {
      cin >> z;
      if (z == '-')
        d[i][j] = 1;
      else
        d[i][j] = 0;
    }
  dfs(0, 0, -1);
  if (ans)
    cout << "YES";
  else
    cout << "NO";
}
