#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 100;
int n;
int k;
vector<int> g[2 * N];
bool doz[2 * N];
string s;
bool pos[2 * N];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    pq;
int d[2 * N];
int p[2 * N];
bool NO;
void dijkstra() {
  for (int i = 1; i <= 2 * n + 1; i++) {
    d[i] = -1;
    p[i] = -1;
  }
  d[1] = 1;
  p[1] = 0;
  pq.push(pair<int, int>(0, 1));
  for (int i = 1; i <= 2 * n + 1; i++) {
    int v = -1;
    while (!pq.empty()) {
      int u = pq.top().second;
      pq.pop();
      if (!pos[u]) {
        v = u;
        pos[v] = true;
        break;
      }
    }
    if (v == -1) break;
    pos[v] = true;
    for (int k = 0; k < g[v].size(); k++) {
      if (!pos[g[v][k]])
        if (d[g[v][k]] == -1 || d[g[v][k]] > d[v] + 1) {
          d[g[v][k]] = d[v] + 1;
          p[g[v][k]] = v;
          pq.push(pair<int, int>(d[g[v][k]], g[v][k]));
        }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  cin >> s;
  for (int i = 1; i <= n; i++)
    if (s[i - 1] == '-') doz[i] = true;
  cin >> s;
  for (int i = 1; i <= n; i++)
    if (s[i - 1] == '-') doz[n + i] = true;
  doz[2 * n + 1] = true;
  for (int i = 1; i < n; i++) {
    if (!doz[i]) continue;
    if (doz[i + 1]) g[i].push_back(i + 1);
    if (doz[i - 1]) g[i].push_back(i - 1);
    if (i > n - k)
      g[i].push_back(2 * n + 1);
    else if (doz[i + k + n])
      g[i].push_back(i + k + n);
  }
  g[n].push_back(2 * n + 1);
  for (int i = n + 1; i < 2 * n; i++) {
    if (!doz[i]) continue;
    if (i > n + 1)
      if (doz[i - 1]) g[i].push_back(i - 1);
    if (doz[i + 1]) g[i].push_back(i + 1);
    if (i > 2 * n - k)
      g[i].push_back(2 * n + 1);
    else if (doz[i + k - n])
      g[i].push_back(i + k - n);
  }
  g[2 * n].push_back(2 * n + 1);
  dijkstra();
  int itr = 2 * n + 1;
  while (itr != 0) {
    if (itr <= n) {
      if (d[itr] > itr) {
        NO = true;
        break;
      }
    } else {
      if (d[itr] > itr - n) {
        NO = true;
        break;
      }
    }
    itr = p[itr];
  }
  if (NO)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
