#include <bits/stdc++.h>
using namespace std;
[[maybe_unused]] const int MAX = INT32_MAX, MIN = -INT32_MAX,
                           maxInd = 1E6 + 1E5 + 1;
[[maybe_unused]] bool directed = true, end_now = false;
bool possible = false;
int n, k;
struct node_data_structure {
  int pre = 0, post = 0;
  bool visited = false, processed = false;
} nodes[maxInd];
vector<int> graph[maxInd];
void insert_graph(int pre, int post) {
  graph[pre].push_back(post);
  nodes[pre].post++;
  nodes[post].pre++;
  if (!directed) {
    graph[post].push_back(pre);
    nodes[post].post++;
    nodes[pre].pre++;
  }
}
[[maybe_unused]] void undoVisit() {
  for (auto &i : nodes) {
    i.visited = false;
    i.processed = false;
  }
  end_now = false;
}
void dfs(int u, int ac = 1) {
  if (end_now) return;
  if (u > 1E6) {
    if (u - 1E6 < ac) return;
    if (u - 1E6 + k > n || u - 1E6 == n) {
      end_now = true;
      possible = true;
      return;
    }
  } else {
    if (u < ac) return;
    if (u + k > n || u == n) {
      end_now = true;
      possible = true;
      return;
    }
  }
  nodes[u].visited = true;
  for (int v : graph[u]) {
    if (!nodes[v].visited) {
      dfs(v, ac + 1);
    }
  }
  nodes[u].processed = true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s1, s2;
  cin >> n >> k >> s1 >> s2;
  for (int i = 1; i < n; i++) {
    if (i + k <= n) {
      if (s1[i - 1] == '-' && s2[i - 1 + k] == '-') {
        insert_graph(i, 1E6 + i + k);
      }
      if (s2[i - 1] == '-' && s1[i - 1 + k] == '-') {
        insert_graph(1E6 + i, i + k);
      }
    }
    if (s1[i] == '-' && s1[i - 1] == '-') {
      insert_graph(i, i + 1);
      insert_graph(i + 1, i);
    }
    if (s2[i] == '-' && s2[i - 1] == '-') {
      insert_graph(1E6 + i, 1E6 + i + 1);
      insert_graph(1E6 + i + 1, 1E6 + i);
    }
  }
  dfs(1);
  possible ? cout << "YES" << endl : cout << "NO" << endl;
  return 0;
}
