#include <bits/stdc++.h>
using namespace std;
void printv(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << ' ';
  }
  cout << '\n';
}
long long be(long long m, long long n, long long mod) {
  long long res = 1;
  while (n) {
    if (n % 2 != 0) {
      res *= m;
      res %= mod;
    }
    m *= m;
    m %= mod;
    n /= 2;
  }
  return res;
}
void sieve(long long n, vector<bool> &prime) {
  prime[0] = false;
  prime[1] = false;
  for (long long i = 2; i * i <= n; i++) {
    if (prime[i] == true) {
      for (long long j = i * i; j <= n; j += i) prime[j] = false;
    }
  }
}
void print(queue<pair<long long, long long> > q) {
  while (!q.empty()) {
    cout << q.front().first << ' ';
    cout << q.front().second << '\n';
    q.pop();
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<string> v(2);
  cin >> v[0];
  cin >> v[1];
  set<pair<long long, long long> > s;
  for (long long i = 0; i < 2; i++)
    for (long long j = 0; j < n; j++)
      if (v[i][j] == '-') s.insert({i, j});
  queue<long long> q;
  q.push(0);
  q.push(0);
  q.push(0);
  map<pair<long long, long long>, long long> mp;
  mp[{0, 0}] = 1;
  long long lev = 0;
  while (!q.empty()) {
    long long a = q.front();
    q.pop();
    long long b = q.front();
    q.pop();
    lev = q.front();
    q.pop();
    long long aa, bb;
    aa = a;
    bb = b + 1;
    if (bb > lev && bb >= n) {
      cout << "YES\n";
      return;
    }
    if (!mp[{aa, bb}] && bb > lev && s.count({aa, bb})) {
      mp[{aa, bb}] = 1;
      q.push(aa);
      q.push(bb);
      q.push(lev + 1);
    }
    aa = a;
    bb = b - 1;
    if (!mp[{aa, bb}] && bb > lev && s.count({aa, bb})) {
      mp[{aa, bb}] = 1;
      q.push(aa);
      q.push(bb);
      q.push(lev + 1);
    }
    aa = a ^ 1;
    bb = b + k;
    if (bb > lev && bb >= n) {
      cout << "YES\n";
      return;
    }
    if (!mp[{aa, bb}] && bb > lev && s.count({aa, bb})) {
      mp[{aa, bb}] = 1;
      q.push(aa);
      q.push(bb);
      q.push(lev + 1);
    }
  }
  cout << "NO\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
