Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		t, _ := strconv.Atoi(scanner.Text())
		if t == 0 {
			break
		}
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		for i  := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			s, _ := strconv.Atoi(buf[0])
			f, _ := strconv.Atoi(buf[1])
			t -= (f-s)
		}
		if t <= 0 {
			fmt.Println("OK")
		} else {
			fmt.Println(t)
		}
	}
}

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

int main()
{
    int t,n,s,f,sum;
    
    while(cin>>t,t){
        cin>>n;
        for(int i=0; i<n; i++){
            cin>>s>>f;
            sum +=(f-s);
        }
        
        if(sum>=t){
            cout<<"OK"<<endl;
        }
        else{
            cout<<t-sum<<endl;
        }
    }
    
    return 0;
}

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

int main()
{
  int t, n, s, f, ans;
  while(true)
  {
    t = n = s = f = ans = 0;
    cin >> t;
    if(!t)
      break;

    cin >> n;
    for(int i = 0; i < n; i++)
    {
      cin >> s >> f;
      ans += f - s;
    }

    if(ans >= t)
      cout << "OK\n";
    else
      cout << t - ans << endl;
  }
}

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

int main()
{
  int t;

  while (cin >> t && t != 0){
    int n;
    int sum = 0;
    cin >> n;
    while (n--){
      int s, f;
      cin >> s >> f;
      sum += (f - s);
    }
    if (sum >= t) cout << "OK" << endl;
    else cout << n - sum << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main()
{
	int t = 0;
	while (cin >> t&&t) {
		int n = 0;
		int fa[10] = {};
		int fb[10] = {};
		cin >> n;
		int ts = 0;
		for (int i = 0; i < n; i++) {
			cin >> fa[i] >> fb[i];
			ts += (fb[i] - fa[i]);
		}
		if (ts >= t) {
			cout << "OK" << endl;
		}
		else{
			cout << t - ts << endl;
		}
	}

	return 0;
	
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int t;
    while(cin >> t, t){
        int n;
        cin >> n;
        for (int i = 0; i < n; ++i) {
            int a, b;
            cin >> a >> b;
            t -= b-a;
        }
        if(t <= 0) puts("OK");
        else cout << t << "\n";
    }
    return 0;
}

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

main(){
	int t ;
	while( cin >> t , t ){
		int n,s,f,sum=0 ;
		cin >> n ;
		for( int i=0 ; i<n ; i++ ){
			cin >> s >> f ;
			sum += f - s ;
		}
		if( sum >= t ) cout << "OK" << endl ;
		else cout << t - sum << endl ;
	}	
}

C++: #include <iostream>
using namespace std;
int main (void)
{
	while(true)
	{
		int n, m, p;
		p = 0;
		cin >> n;
		if(n = 0) 
		{
			break;
		}
		cin >> m;
		while(m > 0)
		{
			int s, q;
			cin >> s >>q;
			p += q-s;
			m--;
		}
		if(p >= n)
		{
			cout << "OK"<< endl;
		}
		else
		{
			cout << n - p;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  while(1){
    long long t,n;
    cin>>t;
    if(t==0) break;
    cin>>n;
    long long sum=0;
    for(int i=0;i<n;i++){
      long long a,b;
      cin>>a>>b;
      sum+=b-a;
    }
    if(sum>=t) cout<<"OK"<<endl;
    else cout<<t-sum<<endl;
  }
}

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

int main(){
   int t, n, s, f, sum;
   while(1){
   sum = 0;
   cin >> t;
   if(t == 0) break;
   cin >> n;
   for(int i = 0;i < n;++i){
     cin >> s >> f;   
     sum += f - s;
    }
   if(sum >= t) cout << "OK" << endl;
   else cout << t - sum << endl;
  }
  return 0;
}

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

int main(){
	int t;
	while(cin >> t && t){
		int n;
		cin >> n;
		int s = 0;
		for(int i = 0 ; i < n; i++){
			int a,b;
			cin >> a >> b;
			s += b-a;
		}
		if( s >= t ){
			cout << "OK" << endl;
		}else{
			cout << t - s << endl;
		}
	}
}

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

int main()
{
    int t,n,s,f,sum;
    cin>>t;
    
    while(cin>>n,n){
        for(int i=0; i<n; i++){
            cin>>s>>f;
            sum +=(f-s);
        }
        
        if(sum>=t){
            cout<<"OK"<<endl;
        }
        else{
            cout<<t-sum;
        }
    }
    
    return 0;
}

C++: #include <stdio.h>

int main(void){
	int t,n,s,f;
	
	while (scanf("%d", &t), t){
		scanf("%d", &n);
		for (; n>=0; n--){
			scanf("%d %d", &s, &f);
			t -= (f-s);
		}
		if (t<0) puts("OK");
		else printf("%d\n", t);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int t, n, s, f, total;
    while(1){
        cin >> t >> n;
        total=0;
        if(t == 0) break;
        for(int i=0; i<n; i++){
            cin >> s >> f;
            total += f-s;
        }
        if(t>total){
            cout << t-total << endl;
        }
        else cout << "OK" << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int a,b,i;
	int aa,bb;
	int time=0,sa;
	while(1){
		cin >> a;
		if(a==0) break;
		cin >> b;
		for(i=0;i<b;i++){
			cin >> aa >> bb;
			sa=bb-aa;
			time=time+sa;
		}
		if(time>=a){
			cout << "OK" << endl;
		}else if(time<a){
			cout << a-time << endl;
		} 
		
		time=0;
}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int t,n,s,f;
	while(1){
		cin>>t;
		if(t==0) break;
		cin>>n;
		int sum=0;
		rep(i,0,n){
			cin>>s>>f;
			sum+=f-s;
		}
		if(sum>=t) o("OK");
		else o(t-sum);
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int t;
	while (cin >> t, t) {
		int n; cin >> n;
		int sum = 0;
		rep(i, n) {
			int s, f; cin >> s >> f;
			sum += f - s;
		}
		printf(sum < t ? "%d\n" : "OK\n", t - sum);
	}
}

C++: #include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int main(){
	int n, t;
	while(cin >> t, t){
		cin >> n;
		rep(i, n){
			int s, f;
			cin >> s >> f;
			t -= f - s;
		}
		if(t <= 0) cout << "OK" << endl;
		else cout << t << endl;
	}
	return 0;
}

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

int main(){
  int t,n,s,f,r;

  cin >> t;
  while(t){
    r = 0;
    cin >> n;
    for(int i=0; i<n; i++){
      cin >> s >> f;
      r += (f-s);
    }
    if(r >= t)
      cout << "OK\n";
    else
      cout << t-r << endl;
    cin >> t;
  }

  return 0;
}

C++: //05
#include<iostream>

using namespace std;

int main(){
  for(int t;cin>>t,t;){
    int n;
    int sm=0;
    cin>>n;
    while(n--){
      int s,f;
      cin>>s>>f;
      sm+=f-s;
    }
    if(sm>=t){
      cout<<"OK"<<endl;
    }else{
      cout<<t-sm<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int t,n,s,f,a,i;
while(cin>>t,t){
cin>>n;
for(a=i=0;i<n;i++){
cin>>s>>f;
a+=f-s;
}
if(a>=t)cout<<"OK"<<endl;
else cout<<t-a<<endl;
}
return 0;
}