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 <stdio.h>

int main(void) {
	int t, n, s, f;
	int i;
	int sum;

	while(1) {
		scanf("%d", &t);
		if(!t)
			break;
		scanf("%d", &n);

		for(i = 0, sum = 0; i < n; i++) {
			scanf("%d %d", &s, &f);
			sum += f - s;
		}

		if(sum >= t)
			printf("OK\n");
		else
			printf("%d\n", t - sum);
	}

	return 0;
}

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

int main()
{
    int t,n,s,f,sum;
    
    while(cin>>t&&t){
        cin>>n;
        sum=0;
        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<string>
#include<algorithm>
#include<sstream>
#include <functional>
using namespace std;


int 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;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void){
	int t,n,s,f;
	
	while (scanf("%d", &t), t){
		scanf("%d", &n);
		while (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()
{
	while(true){
		int t,n;
		int a,f;
		int sum=0;

		cin >> t;
		if(t==0)
			break;

		cin >> n;
		for(int i=0 ;i<n ;i++){

			cin >> a >> f;

			sum += (f - a);
		}

		if(sum >= t){
			cout << "OK" << endl;
		}
		else if(sum < t){
			cout << t - sum << endl;
		}

	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int t, n, s, f;
  for(;;) {
    cin >> t;
    if(t == 0) break;
    cin >> n;
    int sum = 0;
    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<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

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

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

int main() {
  int t, n;

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

C++: #include<iostream>
using namespace std;
int main(){
  while(true){
    int t;cin>>t;
    if(t == 0)return 0;

    int n; cin >> n;
    int result= 0;
    for(int i = 0; i < n; i++){
      int time[2] = {};
      cin >>time[0] >> time[1];
      result += time[1]-time[0];
    }
    (result > t)?(cout << "OK"<<endl):(cout<<t-result<<endl);
  }
  return 0;
}

C++: // 2012/07/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int t;
		cin >> t;

		if(t==0)
			break;

		int sum = 0;

		int n;
		cin >> n;

		for(int i=0; i<n; i++){
			int s, f;
			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,sum;
  while(1){
    cin >> t;
    if(t==0) break;
    cin >> n;
    sum=0;
    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 <stdio.h>

int main()
{
	int s,f,t,total;
	int i,j,n;
	
	scanf("%d",&t);
	while(t != 0){
		//初期化
		total = 0;

		scanf("%d",&n);
		for(i = 0; i < n; i++){
			scanf("%d%d",&s,&f);
			total += f-s;
		}

		if(total < t)	printf("%d\n",t-total);
		else			printf("OK\n");

		scanf("%d",&t);
	}

	return 0;
}

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

int main(){
   int t, n, s, f, sum = 0;
   while(1){
   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>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


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

		}
		else cout<<t<<endl;
	}
}

C++: #include<iostream>
using namespace std;
int n,t,s,f,sum;
int main(){
  while(cin>>t&&t){
    cin>>n;
    sum=0;
    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 n;
	while(cin >> n){
		if(n==0)
			break;
		int m;
		cin >> m;
		for(int i=0;i<m;i++){
			int a,b;
			cin >> a >> b;
			n -= b-a;
		}
		if(n>0)
			cout << n << endl;
		else
			cout << "OK" << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>

using namespace std;

int main()
{
  int n, m, s, t, u;

  while(cin >> n && n){
    cin >> m;
    u = 0;
    while(m--){
      cin >> s >> t;
      u += (t-s);
    }
    if(u >= n) cout << "OK" << endl;
    else cout << (n-u) << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,sum;
    
    while(1){ cin >> a; if(a==0) break;
    cin >> b;
    sum=0;
    for(int i=0;i<b;i++){
        cin >>c>>d;
        sum+=(d-c);
    }
    if (sum>=a) cout << "OK" <<endl;
    else cout << a-sum <<endl;
    }
}