#include <bits/stdc++.h>
using namespace std;
long long p1 = 1000000007;
long long mod = 998244353;
long long power(long long x, long long y) {
  long long ans = 1;
  x = x % p1;
  while (y > 0) {
    if (y & 1) ans = (ans * x) % p1;
    y = y >> 1;
    x = (x * x) % p1;
  }
  return ans;
}
int main() {
  long long n, s;
  cin >> n >> s;
  bool a[n + 1], b[n + 1];
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) cin >> b[i];
  vector<long long> tr[2 * n + 1];
  if (a[1] == 0) {
    cout << "No";
    return 0;
  }
  if (a[s] == 1) {
    cout << "Yes";
    return 0;
  }
  for (long long i = s + 1; i <= n; i++) {
    if (a[i] == 1 && b[i] == 1 && b[s] == 1) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}
