#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793;
const double tau = 6.283185307179586;
const double epsilon = 1e-6;
const int INF = 1 << 26;
const int MAXN = 100005;
int vis[MAXN * 2][2];
int graph[MAXN * 2][2];
int n, k;
int convert(char a) {
  if (a == '-') return 1;
  if (a == 'X') return 0;
  return -1;
}
int ss(int a) { return a == 0 ? 1 : 0; }
int bfs(int x, int y) {
  queue<pair<int, pair<int, int> > > q;
  q.push(make_pair(0, make_pair(x, y)));
  int a, b, c;
  while (q.size()) {
    pair<int, pair<int, int> > cur = q.front();
    q.pop();
    a = cur.second.first;
    b = cur.second.second;
    c = cur.first;
    if (c > a) continue;
    if (a + k >= n) {
      cout << "YES" << endl;
      return 1;
    }
    if (vis[a][b] < c) continue;
    if (graph[a + k][ss(b)] == 1) {
      if (a >= n) {
        cout << "YES" << endl;
        return 1;
      }
      if (vis[a + k][ss(b)] == INF) {
        vis[a + k][ss(b)] = c + 1;
        q.push(make_pair(c + 1, make_pair(a + k, ss(b))));
      }
    }
    if (graph[a + 1][b] == 1) {
      if (a >= n) {
        cout << "YES" << endl;
        return 1;
      }
      if (vis[a + 1][b] == INF) {
        vis[a + 1][b] = c + 1;
        q.push(make_pair(c + 1, make_pair(a + 1, b)));
      }
    }
    if (graph[a - 1][b] == 1) {
      if (a >= n) {
        cout << "YES" << endl;
        return 1;
      }
      if (vis[a - 1][b] == INF) {
        vis[a - 1][b] = c + 1;
        q.push(make_pair(c + 1, make_pair(a - 1, b)));
      }
    }
  }
  return 0;
}
int main(int argc, char** argv) {
  scanf("%d %d\n", &n, &k);
  for (int i = 0; i < 2 * n; i++) {
    char a;
    scanf("%c", &a);
    if (a == '\n') {
      i--;
      continue;
    }
    graph[i % n][i / n] = convert(a);
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2 * n; j++) {
      vis[j][i] = INF;
    }
  if (!bfs(0, 0)) cout << "NO" << endl;
  return 0;
}
