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<bits/stdc++.h>
using namespace std;
int flg[1001]={0};
int main(void)
{
	int a,b,n,s,f;
	int i,j;
	
	cin>>a>>b>>n;
	
	flg[a]=1,flg[b]=-1;
	
	for(i=0;i<n;i++){
		cin>>s>>f;
		flg[s]++;
		flg[f]--;
	}
	
	int sum=0,max=-1;
	for(i=0;i<1000;i++){
		sum+=flg[i];
		if(max<sum) max=sum;
	}	
	
	if(max==1) cout<<"0"<<endl;
	else cout<<"1"<<endl;
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
    int a, b;
    cin>>a>>b;
    int N;
    cin>>N;
    int flg = 0;
    for (int i = 0; i < N; i++)
    {
        int s,f;
        cin>>s>>f;
        if(f<=a||b<=s) continue;
        else flg = 1;

        /* code */
    }
    cout<<flg<<endl;
    return 0;
    
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)

using ll = long long;
using namespace std;
ll n, m, o, ans = 0, a, b;
int main() {
	cin >> n >> m >> o;
	rep(i, o) {
		cin >> a >> b;
		if (a > n&&a < m) ans = 1;
		else if (b > n&&b < m) ans = 1;
	}
	cout << ans << endl;
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a,b;
  cin>>a>>b;
  int n;
  cin>>n;
  int imos[2000];
  memset(imos,0,sizeof(imos));
  for(int i=0;i<n;i++){
    int s,f;
    cin>>s>>f;
    imos[s]++;
    imos[f]--;
  }
  for(int i=1;i<2000;i++) imos[i]+=imos[i-1];
  cout<<(*max_element(imos+a,imos+b)>0)<<endl;
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<cstdio>
#include<string>
using namespace std;
int main(){
	int a, b, N;
	cin >> a >> b >> N;
	while (N--){
		int s, f;
		cin >> s >> f;
		if (a <= s&& f <= b){
			cout << 1 << endl;
		    return 0;
		}
		
	}
	cout << 0 << endl;
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int a,b;cin>>a>>b;
    bool f=true;
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int s,f;
        cin>>s>>f;
        if(b<=s||a>=f)continue;
        f=false;
    }
    if(f){
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int n;
    cin >> n;
    int frg=0;
    for(int i=0;i<n;i++){
        int s,f;
        cin >> s >> f;
        if((s<a&&a<f)||(s<b&&b<f)){
            frg=1;
            break;
        }
    }
    cout << frg << endl;
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int a,b;
    cin >> a >> b;
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        int x,y;
        cin >> x >> y;
        if((x <= a && a < y) || (x < b && b <= y)|| (a <= x && y <= b)){
            ans = 1;
        }
    }
    cout << ans << endl;
}

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

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

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep)(__VA_ARGS__)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}

int gcd ( int a, int b ) { int c; while ( a != 0 ) { c = a; a = b%a; b = c; } return b; }
int main(){
    INT(a,b,n);
    rep(i,n){
        INT(s,g);
        if(s<b&&a<g){
            out(1);
            return 0;
        }
    }
    out(0);
}