#include <bits/stdc++.h>
using namespace std;
struct keycompare {
  bool operator()(const pair<long long, long long>& v, const long long& k) {
    return (v.first < k);
  }
  bool operator()(const long long& k, const pair<long long, long long>& v) {
    return (k < v.first);
  }
};
long long mod1 = 998244353, mod2 = 1000000007, limit = 9223372036854775807;
long double pi = 3.1415926535897932;
long long modpow(long long x, long long n, long long m) {
  if (x > m) {
    x %= m;
  }
  if (n == 0) return 1 % m;
  long long u = modpow(x, n / 2, m);
  u = (u * u) % m;
  if (n % 2 == 1) u = (u * x) % m;
  return u;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool isprime(long long n) {
  if (n == 2) return true;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long power(long long x, long long n) {
  if (n < 0) {
    return 0;
  }
  long long x_n = 1;
  for (long long i = 0; i < n; i++) {
    x_n *= x;
  }
  return x_n;
}
int dist[200005][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i < 200005; i++) {
    dist[i][0] = 100000000;
    dist[i][1] = 100000000;
  }
  int n, k;
  cin >> n >> k;
  string l, r;
  cin >> l >> r;
  queue<pair<int, pair<int, int>>> q;
  q.push({0, {0, 0}});
  dist[0][0] = 0;
  while (!q.empty()) {
    int d = q.front().first, h = q.front().second.first,
        col = q.front().second.second;
    q.pop();
    if (d <= h && ((col == 0 && l[h] == '-') || (col == 1 && r[h] == '-'))) {
      if (h + k >= n) {
        cout << "YES";
        return 0;
      } else {
        if (dist[h + 1][col] > d + 1) {
          dist[h + 1][col] = d + 1;
          q.push({d + 1, {h + 1, col}});
        }
        if (h - 1 >= 0 && dist[h - 1][col] > d + 1) {
          dist[h - 1][col] = d + 1;
          q.push({d + 1, {h - 1, col}});
        }
        if (dist[h + k][!col] > d + 1) {
          dist[h + k][!col] = d + 1;
          q.push({d + 1, {h + k, !col}});
        }
      }
    }
  }
  cout << "NO";
}
