#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100005];
vector<int> graphcolor[100005];
int dist[100005];
int par[100005];
int visited[100005];
int n, k;
int step;
int color, dist1, dist2;
int arr[105];
int sum = 0;
char string1[100005];
char string2[100005];
void dfs(int s, int w, int flag) {
  int u, i;
  if (s + k >= n) {
    printf("YES\n");
    exit(0);
  }
  if (flag == 1) string1[s] = 'X';
  if (flag == 2) string2[s] = 'X';
  if (s - 1 > w + 1) {
    if (flag == 1)
      if (string1[s - 1] == '-' && s - 1 >= 0) dfs(s - 1, w + 1, 1);
    if (string2[s - 1] == '-' && flag == 2 && s > 0) dfs(s - 1, w + 1, 2);
  }
  if (flag == 1) {
    if (string2[s + k] != 'X') dfs(s + k, w + 1, 2);
  } else if (flag == 2) {
    if (string1[s + k] != 'X') dfs(s + k, w + 1, 1);
  }
  if (string1[s + 1] != 'X' && flag == 1)
    dfs(s + 1, w + 1, 1);
  else if (string2[s + 1] != 'X' && flag == 2)
    dfs(s + 1, w + 1, 2);
}
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  int u, v;
  int j;
  cin >> string1;
  cin >> string2;
  dfs(0, -1, 1);
  printf("NO");
  return 0;
}
