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 {
		fmt.Println(0)
	}
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vi a(10000);
int n,l,r;

int main(){
	cin>>l>>r>>n;
	for(int i=0;i<n;i++){
		int L,R;
		cin>>L>>R;
		for(int j=L;j<R;j++) a[j]=1;
	}
	for(int i=l;i<r;i++){
		if(a[i]){
			cout<<1<<endl;
			return 1;
		}
	}
	cout<<0<<endl;
}

C++: #include<stdio.h>
int main()
{
	int i,a,b,n,s,f;
	scanf("%d%d",&a,&b);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&s,&f);
		if((s<a&&a<f)||(a<s&&b>f)||(s<b&&f>b)||(s<a&&b<f)){
			printf("1\n");
			return 0;
		}
	}
	printf("0\n");
    return 0;
}

C++: #include <bits/stdc++.h>

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
     cin >> a >> b >> n;
     rep(i,n){
       cin >> c >> d;
       if(c < a && a < d)ans = 1;
       else if(a <= c && b >= d)ans = 1;
       else if(c < b && b < d)ans = 1;
     }
     Cout(ans);
     

       
return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a,b,n,s,f,i=0;
  cin >> a >> b >> n;
  do{
    cin >> s >> f;
    i++;
  }while((a != s && b != f) && (s <= a && s >= b) && (f <= a && s >= b));
  if(n == i-1){
    cout << '0' << endl;
  } else {
    cout << '1' << endl;
  }
}

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;
		}
		if(c<a&&b<d){
			cout<<"1"<<endl;
			return 0;
		}
		if(a==c){
			cout<<"1"<<endl;
			return 0;
		}
		if(b==d){
			cout<<"1"<<endl;
			return 0;
		}
		c=0;
		d=0;
	}
	cout<<"0"<<endl;
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,n,s,f,i,j,flg;
	cin>>a>>b>>n;
	flg=0;
	for(i=0;i<n;i++){
		cin>>s>>f;
		if(b>s && a<f){
			flg=1;
		}
	}
	cout<<flg<<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[1000];
  for(int i=0;i<N;i++){
    cin >> s >> f;
    for(int j=s;j<=f;j++){
      ans[j]=1;
    }
  }

  if(ans[a+1]==1 || ans[b-1]==1){
    cout << '1' << endl;
  }else{
    cout << '0' << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
  int a,b; cin >> a >> b;
  int n; cin >> n;
  int s,f;
  int t[1005]={};
  t[a]++; t[b]--;
  for(int i=0;i<n;++i){
    cin >> s >> f;
    t[s]++; t[f]--;
  }
  int ans=0,flag=0;
  for(int i=0;i<=1000;++i) t[i+1]+=t[i];
  for(int i=a;i<=b;++i){
    if(t[i]>1)ans=1;
  }
  cout << ans << endl;
  
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int n;
  cin >> n;
  pair <int,int> s[n];
  for(int i = 0;i<n;i++){
    int x,y;
    cin >> x >> y;
    s[i].first = x;
    s[i].second = y;
  }
  sort(s,s+n);
  int f = 0;
  while(s[f].first < a){
    
    f++;
    if(f > n-1){
      break;
    }
  }
  f--;
  if(f == n-1){
    if(n != 0){
      if(s[f].second <= a && s[f+1].first >= b)
	cout << '0'<< endl;
      else
	cout << '1' << endl;
    }
    else{
      cout << '0'  << endl;
    }
  }
  else{
    cout << '0' << endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,n,x,y,chk=0;
    scanf("%d %d",&a,&b);
    scanf("%d",&n);
    for(int  i=0;i<n;++i){
        scanf("%d %d",&x,&y);
        if(x<=a && x<b && a<y && y<=b) chk++;
        if(a<=x && x<b && a<y && b<=y) chk++;
    }
    if(chk==0) cout <<"0"<< endl;
    else if(0<chk) cout <<"1"<< endl;
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int a, b, N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> a >> b >> N; b--;
    rep(i, 0, N) {
        int s, f; cin >> s >> f; f--;
        if (b < s) continue;
        if (f < a) continue;
        printf("1\n");
        return;
    }
    printf("0\n");
    return;
}