Go: package main

import "fmt"

func main() {
	var sTime, fTime, exists, eSTime, eFTime int

	fmt.Scan(&sTime, &fTime)
	fmt.Scan(&exists)

	var flag bool

	for i := 0; i < exists; i++ {
		fmt.Scan(&eSTime, &eFTime)

		if sTime > eSTime && sTime < eFTime {
			flag = true
		}
		if fTime > eSTime && fTime < eFTime {
			flag = true
		}
		if eSTime > sTime && eFTime < fTime {
			flag = true
		}
	}

	if flag {
		fmt.Println(1)
	} else {package main

import "fmt"

func main() {
	var sTime, fTime, exists, eSTime, eFTime int

	fmt.Scan(&sTime, &fTime)
	fmt.Scan(&exists)

	var flag bool

	for i := 0; i < exists; i++ {
		fmt.Scan(&eSTime, &eFTime)

		if sTime > eSTime && sTime < eFTime {
			flag = true
		}
		if fTime > eSTime && fTime < eFTime {
			flag = true
		}
		if eSTime > sTime && eFTime < fTime {
			flag = true
		}
	}

	if flag {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

		fmt.Println(0)
	}
}

C++: #include <iostream>
using namespace std;

int main(){
    bool res[1001];
    int a, b, N;
    bool ans = false;

    cin >> a >> b;
    for(int i=a;a<b;a++)
        res[i] = true;

    cin >> N;
    for(int i=0;i<N;i++){
        int s,f;
        cin >> s >> f;
        for(int j=s;j<f;j++){
            if(res[j])
                ans = true;
        }
    }

    cout << ans << endl;

    return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;

  int N;
  cin >> N;

  int s,f;
  int ans=0;
  for(int i=0;i<N;i++){
    cin >> s >> f;
    if(s<=a && a<f){
      ans++;
    }else if(s<b && b<=f){
      ans++;
    }else if(a<=s && f<=b){
      ans++;
    }
  }

  if(ans>0){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    int a,b,n;
    cin >>a >>b >>n;
    vector<vector<int>> vec(n,vector<int>(2));
    for(int i=0;i<n;i++){
        cin>>vec.at(i).at(0)>>vec.at(i).at(1);
    }
    vector<int> cat(1000,0);
    for(int i=0;i<n;i++){
        cat.at(vec.at(i).at(0)-1) ++;
        cat.at(vec.at(i).at(1)-1) --;
    }
    cat.at(a-1) ++;
    cat.at(b-1) --;
    vector<int> rsw(1001);
    rsw.at(0) =0;
    for(int i=1;i<1001;i++){
        rsw.at(i) = rsw.at(i-1) + cat.at(i-1);
    }
    for(int i=0;i<1001;i++){
        if(rsw.at(i) == 2){
            cout << 1 << endl;
            break;
        }else if(i==1000){
            cout << 0 << endl;
        }
    }


}

C++: #include <iostream>

using namespace std;

int main() {
    int h[1010] = {0};
    int a, b;
    cin >> a >> b;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int s, f;
        cin >> s >> f;
        for(int j = s; j < f; j++) {
            h[j]++;
        }
    }
    for(int i = a; i < b; i++) {
        if(h[i] > 0) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    // for(int i = 0; i < 1010; i++) {
    //     cout << h[i] << " ";
    //     if(i % 20 == 0) cout << endl;
    // }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <set>
#include<list>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    rep(i, n){
        int s, f;
        cin >> s >> f;
        if(!(b <= s || a >= f)){
            cout << 1 << "\n";
            return 0;
        }
    }
    cout << 0 << "\n";

    return 0;
}

C++: #include<iostream>

using namespace std;



int main(){

    int a,b;

    cin>>a>>b;

    int N;

    cin>>N;

    bool flag=0;

    for(int i=0;i<N;i++){

        int s,f;

        cin>>s>>f;

        if((a<f&&b>s)||(s<b&&f>a))flag=1;

    }

    cout<<flag<<endl;

    return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a, b, n;
  cin >> a >> b >> n;
  bool ok = true;
  for(int i = 0; i < n; ++i) {
    int s, f;
    cin >> s >> f;
    
    if((s < a && a < f) || (s < b && b < f) || (a <= s && f <= b)) ok = false;
  }
  if(ok) cout << 0 << endl;
  else cout << 1 << endl;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,n,k[101],l[101],x=0;
    cin>>a>>b>>n;
    for(int i=0;i<=n;i++){
       cin>>k[i]>>l[i];
if(k[i]>a&&l[i]<b){
          x=1;
          break;
       }
    }
    cout<<x<<endl;
    return 0;
}

C++: //============================================================================
// Name        : tokuteigai.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b,c,d,n;
	cin>>a>>b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c>>d;
		if(a<d&&d<b){
			cout<<"1"<<endl;
			return 0;
		}
		if(c<b&&a<c){
			cout<<"1"<<endl;
			return 0;
		}
		if(a==c&&b==d){
			cout<<"1"<<endl;
			return 0;
		}
	}
	cout<<"0"<<endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	int n; cin >> n;
	int b00l = 0;
	for (int i = 0; i < n; i++) {
		int c, d; cin >> c >> d;
		if (c < b&&a < d) {
			b00l = 1;
		}
	}
	cout << b00l << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll a,b;cin>>a>>b;
    ll n;cin>>n;
    rep(i,n){
        ll s,t;cin>>s>>t;
        if(s<b&&a<t)dame(1);
    }
    out(0);
}