#include <bits/stdc++.h>
using namespace std;
int d[200005][2];
int main() {
  srand((unsigned int)time(NULL));
  int n, k;
  cin >> n >> k;
  string le[2];
  cin >> le[0] >> le[1];
  for (int i = 0; i < 2; i++)
    while (le[i].size() < 200000) le[i].push_back('-');
  for (int i = 1; i <= 200000; i++) {
    for (int j = 0; j < 2; j++) {
      d[i][j] = 1000000000;
    }
  }
  priority_queue<pair<int, pair<int, int> >,
                 vector<pair<int, pair<int, int> > >,
                 greater<pair<int, pair<int, int> > > >
      que;
  d[1][0] = 1;
  que.push(make_pair(1, make_pair(1, 0)));
  while (!que.empty()) {
    pair<int, pair<int, int> > p = que.top();
    que.pop();
    if (p.first != d[p.second.first][p.second.second]) continue;
    int time = p.first;
    int height = p.second.first;
    int side = p.second.second;
    if (time + 1 <= height - 1 && 1 <= height - 1 &&
        le[side][height - 2] == '-' && d[height - 1][side] > time + 1) {
      d[height - 1][side] = time + 1;
      if (height - 1 <= n)
        que.push(make_pair(time + 1, make_pair(height - 1, side)));
    }
    if (time + 1 <= height + 1 && 1 <= height + 1 && le[side][height] == '-' &&
        d[height + 1][side] > time + 1) {
      d[height + 1][side] = time + 1;
      if (height + 1 <= n)
        que.push(make_pair(time + 1, make_pair(height + 1, side)));
    }
    if (time + 1 <= height + k && 1 <= height + k &&
        le[1 - side][height + k - 1] == '-' &&
        d[height + k][1 - side] > time + 1) {
      d[height + k][1 - side] = time + 1;
      if (height + k <= n)
        que.push(make_pair(time + 1, make_pair(height + k, 1 - side)));
    }
  }
  for (int i = n + 1; i <= 200000; i++)
    for (int j = 0; j < 2; j++)
      if (d[i][j] != 1000000000) {
        cout << "YES" << endl;
        return 0;
      }
  cout << "NO" << endl;
}
