#include <bits/stdc++.h> 
using namespace std;
#define FOR(i,l,r) for(size_t i=(l); i<(r); i++)
#define REP(i,n) FOR(i,0,n)
#define endl "\n"
#define debug(x) cout<<x<<endl;
typedef long long ll;
static const ll INF = 1ll<<60;

int main(){
    int N,S,D;
    cin>>N>>S>>D;
    vector<int> X(N),Y(N);
    REP(i,N) cin>>X[i]>>Y[i];

    bool flag = false;

    REP(i,N){
        if(X[i]  >= S) continue;
        if(Y[i] <= D) continue;
        flag = true;
    }

    cout<<(flag ? "Yes" : "No")<<endl;
}
#include <iostream>

using namespace std;

int n;
string s , t;
int a[500010] , cnt;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> s >> t;
	for(int i = 0; i < n; i++)
		if(s[i] == '1')
			a[++cnt] = i;
	int temp = 1;
	long long ans = 0;
	for(int i = 0; i < n; i++)
		if(t[i] == '1')
		{
			while(a[temp] < i && temp <= cnt)
			{
				if(temp == cnt)
				{
					cout << -1 << endl;
					return 0;
				}
				ans += a[temp + 1] - a[temp] , temp += 2;
			}
			if(temp == cnt + 1)
			{
				cout << -1 << endl;
				return 0;
			}
			ans += a[temp] - i , temp++;
		}
	while(temp <= cnt)
	{
		if(temp == cnt)
		{
			cout << -1 << endl;
			return 0;
		}
		ans += a[temp + 1] - a[temp] , temp += 2;
	}
	cout << ans << endl;
	return 0;
}