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>

using namespace std;

int main(int argc, char const *argv[]) {
    int t, n, s, f;
    int total;
    while (cin>>t, t) {
        total = 0;
        cin>>n;
        for (int i = 0; i < n; ++i) {
            cin>>s>>f;
            int tmp = f - s;
            total += tmp;
        }

        if (total >= t) cout<<"OK"<<endl;
        else cout<< t - total << endl;

    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int t, n, s, f;
  while(cin >> t, t){
    cin >> n;
    int sum = 0;
    while(n--){
      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<cstring>
#include<algorithm>
using namespace std;
main(){
  while(1){
    int T,N,s,f,sum=0;
    scanf("%d",&T);
    if(T==0) break;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
      scanf("%d %d",&s,&f);
      sum+=(f-s);
    }
    if(sum>=T) puts("OK");
    else printf("%d\n",T-sum);
  }
}

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

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

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);
}