#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
char a[N], b[N];
bool vis[2][N];
int n, k;
struct node {
  int num;
  bool flag;
  int step;
};
bool isSuccess = false;
queue<node> qu;
void bfs() {
  qu.push(node{1, 0, 0});
  vis[0][1] = 1;
  while (!qu.empty()) {
    node now = qu.front();
    qu.pop();
    if (now.num + 1 > n || now.num + k > n) {
      isSuccess = true;
      break;
    }
    if (now.flag == 0) {
      if (now.num + 1 > now.step + 1 && a[now.num + 1] == '-' &&
          !vis[0][now.num + 1]) {
        vis[0][now.num + 1] = 1;
        qu.push(node{now.num + 1, 0, now.step + 1});
      }
      if (now.num - 1 > now.step + 1 && a[now.num - 1] == '-' &&
          !vis[0][now.num - 1]) {
        vis[0][now.num - 1] = 1;
        qu.push(node{now.num - 1, 0, now.step + 1});
      }
      if (now.num + k > now.step + 1 && b[now.num + k] == '-' &&
          !vis[1][now.num + k]) {
        vis[1][now.num + k] = 1;
        qu.push(node{now.num + k, 1, now.step + 1});
      }
    } else {
      if (now.num + 1 > now.step + 1 && b[now.num + 1] == '-' &&
          !vis[1][now.num + 1]) {
        vis[1][now.num + 1] = 1;
        qu.push(node{now.num + 1, 1, now.step + 1});
      }
      if (now.num - 1 > now.step + 1 && b[now.num - 1] == '-' &&
          !vis[1][now.num - 1]) {
        vis[1][now.num - 1] = 1;
        qu.push(node{now.num - 1, 1, now.step + 1});
      }
      if (now.num + k > now.step + 1 && a[now.num + k] == '-' &&
          !vis[0][now.num + k]) {
        vis[0][now.num + k] = 1;
        qu.push(node{now.num + k, 0, now.step + 1});
      }
    }
  }
}
int main() {
  cin >> n >> k;
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  isSuccess = false;
  bfs();
  if (isSuccess)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
