#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long ncr(long long n, long long r) {
  long long p = 1, k = 1;
  if (n - r < r) r = n - r;
  if (r != 0) {
    while (r != 0) {
      p *= n;
      k *= r;
      long long temp = gcd(p, k);
      p /= temp;
      k /= temp;
      n--;
      r--;
    }
  } else
    p = 1;
  return p;
}
long long pm(long long x, long long n, long long mod = 1000000007) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = ((result % mod) * (x % mod)) % mod;
    x = ((x % mod) * (x % mod)) % mod;
    n /= 2;
  }
  return result;
}
long long p(long long x, long long n) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = result * x;
    x = x * x;
    n /= 2;
  }
  return result;
}
long long prm(long long x, long long y, long long mod = 1000000007) {
  long long res = 0, z = 1;
  while (y > 0) {
    if (y & 1) res = (res + x) % mod;
    x *= 2;
    x %= mod;
    y >>= 1;
  }
  return res;
}
long long factorial[300000 + 1];
void fact(long long n, long long mod = 1000000007) {
  factorial[0] = 1;
  factorial[1] = 1;
  for (int i = 2; i < n + 1; i++)
    factorial[i] = (i * factorial[i - 1] % mod) % mod;
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(std::numeric_limits<double>::max_digits10);
  ;
  long long t, i, j, k, n, x, y, z, w, p, f = 0;
  cin >> n >> k;
  vector<string> v(2);
  cin >> v[0] >> v[1];
  vector<vector<long long> > lev(n, vector<long long>(2, 1e9));
  lev[0][0] = 0;
  queue<pair<long long, long long> > q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    x = q.front().first;
    y = q.front().second;
    q.pop();
    if (x > 0 && v[y][x - 1] == '-' && x > lev[x][y] &&
        lev[x - 1][y] > lev[x][y] + 1 && x - 1 >= lev[x][y] + 1) {
      q.push(make_pair(x - 1, y));
      lev[x - 1][y] = lev[x][y] + 1;
    }
    if (x < n - 1 && v[y][x + 1] == '-' && lev[x + 1][y] > lev[x][y] + 1) {
      q.push(make_pair(x + 1, y));
      lev[x + 1][y] = lev[x][y] + 1;
    }
    if (x + k >= n)
      f = 1;
    else {
      if (v[1 ^ y][x + k] == '-' && lev[x + k][1 ^ y] > lev[x][y] + 1) {
        q.push(make_pair(x + k, 1 ^ y));
        lev[x + k][1 ^ y] = lev[x][y] + 1;
      }
    }
  }
  if (min(lev[n - 1][0], lev[n - 1][1]) < n) f = 1;
  if (f)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
