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>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int t, n, b, e;
	while(cin >> t, t) {
		cin >> n;
		rep(i,n) {
			cin >> b >> e;
			t -= e-b;
		}
		if(t<=0) cout << "OK" << endl;
		else cout << t << endl;
	}
}

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

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

C++: #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
	int t,n,s[10],f[10];
	while(scanf("%d",&t),t){
		scanf("%d",&n);
		int sum=0;
		for(int i=0;i<n;i++){ scanf("%d%d",&s[i],&f[i]); sum+=f[i]-s[i]; }
		if(sum>=t) printf("OK\n");
		else printf("%d\n",t-sum);
	}	
}

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<bits/stdc++.h>
using namespace std;

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

    return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int t,n,s,f,sum;

int main(){
	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(t>=sum){cout<<"OK"<<endl;}
		else{cout<<t-sum<<endl;}
	}
	return 0;
}

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

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

C++: #include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t, n;
  int cnt;
  int s, f;

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

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 << t - sum << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{	
	int t=0,n=0,s[100]={0},f[100]={0},time=0;
	while(1)
	{
		scanf("%d",&t);
		if(t==0){break;}
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			scanf("%d %d",&s[i],&f[i]);
			time=time+f[i]-s[i];
		}
		if(time>=t)
		{
			printf("OK\n");
		}
		else
		{
			printf("%d\n",t-time);
		}
		time=0;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int t;
  while (cin >> t, t) {
    int n;
    cin >> n;
    int sum = 0;
    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<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int t, n;

    while (~scanf("%d", &t)) {
        if (t == 0) break;
        scanf("%d", &n);
        int cnt = 0;
        int s, f;

        REP (i, n) {
            scanf("%d%d", &s, &f);
            cnt += f - s;
        }

        if (cnt >= t) OUT("OK");
        else OUT(t - cnt);
    }

    return 0;
}

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

C++: #include <cstdio>

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

C++: #include <stdio.h>

int main(void){
	
	int t;
	int n;
	int s,f;
	int i;
	int a=0,b;
	
	while(1){
		a=0;
		scanf("%d",&t);
		if(t==0) break;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			a=a+(f-s);
		}
			if(t<=a){
				printf("OK\n");
			}
			if(t>=a){
				b=t-a;
				printf("%d\n",b);
		}
	}
	return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
	int i;
	int t;
	while(scanf("%d",&t),t){
		int n;
		scanf("%d",&n);
		for(i=0;i<n;++i){
			int p,q;
			scanf("%d%d",&p,&q);
			t-=q-p;
		}
		if(t>0)
			printf("%d\n",t);
		else
			puts("OK");
	}
	return 0;
}

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

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

int main(){
  int a,n,t1,t2;
  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> a;
    for(int i=0;i<a;i++){
      cin >> t1 >> t2;
      n -= t2 - t1;
    }
    if(n <= 0) cout << "OK" << endl;
    else cout << n << endl;
  }
}

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

	return 0;
}