#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
const long long inf = 3e18;
const long long mod = 1e9 + 7;
long long a[maxn][3], n, ans, k;
string s;
map<pair<long long, long long>, vector<pair<long long, long long> > > adj;
map<pair<long long, long long>, long long> dis;
queue<pair<long long, long long> > q;
inline bool check(long long x, long long y, long long d) {
  if (x >= 0 && x < n && a[x][y] == 0 && dis[{x, y}] > d && d <= x) {
    dis[{x, y}] = d;
    return 1;
  }
  return 0;
}
inline void connect(long long x, long long y) {
  if (a[x][y] == 1) return;
  if (check(x + 1, y, dis[{x, y}] + 1)) q.push({x + 1, y});
  if (check(x - 1, y, dis[{x, y}] + 1)) q.push({x - 1, y});
  if (check(x + k, 3 - y, dis[{x, y}] + 1)) q.push({x + k, 3 - y});
  if (check(x - k, 3 - y, dis[{x, y}] + 1)) q.push({x - k, 3 - y});
  return;
}
int main() {
  cin >> n >> k;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == '-')
      a[i][1] = 0;
    else
      a[i][1] = 1;
  }
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == '-')
      a[i][2] = 0;
    else
      a[i][2] = 1;
  }
  if (a[0][1] == 1) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < n + k + 10; i++) {
    dis[{i, 1}] = dis[{i, 2}] = inf;
  }
  q.push({0, 1});
  dis[{0, 1}] = 0;
  while (!q.empty()) {
    pair<long long, long long> fr = q.front();
    q.pop();
    connect(fr.first, fr.second);
  }
  for (int i = n; i + k >= n; i--) {
    if (dis[{i, 1}] <= i || dis[{i, 2}] <= i) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
