#include <bits/stdc++.h>
int n;
int k;
char mass1[100000];
char mass2[100000];
int mass_int1[100000];
int mass_int2[100000];
bool result = false;
void go(int mass_ind, int ind, int water) {
  if (result) {
    return;
  }
  if (ind >= n) {
    result = true;
    return;
  }
  char* mass;
  int* mass_int;
  if (mass_ind == 1) {
    mass = mass1;
    mass_int = mass_int1;
  } else {
    mass = mass2;
    mass_int = mass_int2;
  }
  if (water < ind && mass[ind] == '-' && mass_int[ind] > water) {
    mass_int[ind] = water;
    go(mass_ind == 1 ? 2 : 1, ind + k, water + 1);
    go(mass_ind, ind + 1, water + 1);
    if (ind - 1 >= 0) go(mass_ind, ind - 1, water + 1);
  }
}
int main(int arg, char** argv) {
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    std::cin >> mass1[i];
    mass_int1[i] = 100001;
  }
  for (int i = 0; i < n; ++i) {
    std::cin >> mass2[i];
    mass_int2[i] = 100001;
  }
  go(1, 0, -1);
  if (result) {
    std::cout << "YES";
  } else {
    std::cout << "NO";
  }
  return 0;
}
