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>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

void fin(){
	freopen("test.txt", "r", stdin);
}

int main(){
	while(1){
		int t;
		cin >> t;
		if(!t) break;

		int n;
		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<stdio.h>

int main(){

int G,N;
while(1){
scanf("%d",&G);if(G==0)break;

scanf("%d",&N);
int s,f;
for(int i=0;i<N;i++)
{
scanf("%d %d",&s,&f)
f-=s;
G-=f;
if(G<=0)break;
}
if(G<=0)printf("OK\n");
else printf("%d\n",G);
}
return 0;
}

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

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;





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

C++: #include<iostream>
using namespace std;
int main()
{
		int t,n,s,f;
	while(1){
		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;
	  }
	}
	return 0;
}

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

C++: #include<stdio.h>
int main(void)
{
   int i,a,b,c,d,e;
   scanf("%d %d",&a,&b);
   e=0;
   for(i=0;i<b;i++){
   scanf("%d %d",&c,&d);
   e+=d-c;
   }
   if(a<=e){
   printf("OK\n");
   }
   if(a>e){
   printf("%d\n",a-e);
   }
   return 0;
   }

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    while (cin >> t && t) {
        int n;
        cin >> n;
        int time = 0;
        for (int i = 0; i < n; ++i) {
            int s, f;
            cin >> s >> f;
            time += f - s;
        }
        if (time >= t) {
            cout << "OK" << '\n';
        } else {
            cout << t - time << '\n';
        }
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
    int i,j,k,l;
    int t,n;
    int s,f;
    int sum;
    
    while(true){
        sum=0;
        cin>>t;
        if(t==0)break;
        cin>>n;
        for(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[11],f[11];
  while(1){
    int sum=0;
    cin>>t;
    if(t==0)break;
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>s[i]>>f[i];   
      sum+=f[i]-s[i];
    }
    if(sum>=t)cout<<"OK"<<"\n";
    else cout<<t-sum<<"\n";
  }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

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

    return 0;
}

C++: #include <iostream>
#include <cstdio>

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int m,n;
	int s,f,s1,i;
	
	while(1){
	s1=0;
	cin>>n;
	if(n==0) break;
	cin>>m;
	for(i=0;i<m;i++){
		cin>>s>>f;
		s1+=f-s;
	}
	
	if(s1>=n) cout<<"OK"<<endl;
	else cout<<n-s1<<endl;
	}
	return 0;
}

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

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

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

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int st[101];
int ft[101];
int main(){
  int t;
  int n;
  while(cin>>t&&t){
    cin>>n;
    for(int i=0;i<n;i++)cin>>st[i]>>ft[i];
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=max(0,ft[i]-st[i]);
    }
    if(sum>=t)cout<<"OK"<<endl;
    else cout<<t-sum<<endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

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

C++: #include<stdio.h>
int main(void)
{
    int t,n,i,s,f;
	scanf("%d %d",&t,&n);
	while (1){
	    if (n=0) break;
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			t=t-(f-s);
		}
		if(t<=0){
			printf("OK\n");
		}
		else printf("%d\n",t);
		}
		return 0;
	}
}