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

Python: while True:
    t=int(input())
    if t == 0:
        break
    n=int(input())
    b=0
    for i in range(n):
        s,f=map(int,input().split())
        a=f-s
        b+=a
    if t<=b:
        print("OK")
    else:
        print(t-b)

Python: while 1:
    a=int(input())
    if a == 0: break
    b=int(input())
    for _ in range(b):
        c=list(map(int,input().split()))
        a-=c[1]-c[0]
    print(a if a>0 else 'OK')

Python: while 1:
    t = int(input())
    if t == 0:
        break

    n = int(input())

    ans = 0
    for _ in range(n):
        s, f = map(int, input().split())
        ans += f - s

    if ans >= t:
        print("OK")
    else:
        print(t - ans)

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

int main() {
	// your code goes here
	int m,n,x,y;
	while(true){
	
	cin >> m;
	if(m==0)
	break;
	cin >> n;
	for(int i=0;i<n;i++){
	cin >> x >> y;
	m-=y-x;
	}
	if(m>0)
	cout << m << endl;
	else 
	cout << "OK" << endl; 

	}
		return 0;
}

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

C++: using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int main()
{
	int lim;
	while(cin>>lim&&lim){
		int n;cin>>n;
		int ans=0;
		while(n--){
			int a,b;cin>>a>>b;
			ans+=b-a;
		}
		if(ans<lim)printf("%d\n",lim-ans);
		else printf("OK\n");
	}
    return 0;
}

C++: #include <stdio.h>

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

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

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

int main() {
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		int c;
		cin >> c;
		for (int b = 0; b < c; b++) {
			int d, e;
			cin >> d >> e;
			a -= e - d;
		}
		(a > 0) ? (cout << a << endl) : (cout << "OK" << endl);
	}
}

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

int main(){
  int t,n;
  while(1){
    cin >> t;
    if(t==0) break;
    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>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int t, n;
    while (cin >> t, t) {
        cin >> n;
        int s, f, sum = 0;
        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<stdio.h>
int main()
{
	int i,t,n,s,f;
	while(1){
		scanf("%d",&t);
		if(t==0){
			break;
		}
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d%d\n",&s,&f);
			t-=(f-s);
		}
		if(t<=0){
			printf("OK\n");
		}else{
			printf("%d\n",t);
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int t;
	while(cin >> t, t){
		int n, sum=0;
		cin >> n;
		rep(i,n){
			int s, f;
			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,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;
        }
        sum=0;
    }
    return 0;
}

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

int main(){
  int t,n,s,f,r=0;
  cin >> n;
  while(n){
    cin >> t;
    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 >> n;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

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

  }
  return 0;
}

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

int main()
{
	int t, n, s, f, sum;
	while(cin >> t && t != 0){

		sum = 0;

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

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){

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

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

}

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

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

	}
	return 0;
}

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

vector<int> ans;

int main(){
  int t,n;
  while(cin >> t,t){
    int tmp_t = t;
    cin >> n;
    for(int i=0; i<n; ++i){
      int a,b;
      cin >> a >> b;
      tmp_t -= (b-a);
    }
    ans.push_back(tmp_t);
  }
  
  for(auto i:ans){
    if(i<1){
      cout << "OK" << endl;
    }else{
      cout << i << endl;
    }
  }
  return 0;
}

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

int main(){
  while(true){
    int mt,n;
    cin>>mt;
    if(mt==0){
      break;
    }
    cin>>n;
    int st,et,total=0;
    for(int i=0;i<n;i++){
      cin>>st>>et;
      total=total+et-st;
    }
    if(total>=mt){
      cout<<"OK"<<endl;
    }else if(total<mt){
      cout<<mt-total<<endl;
    }
  }
  
    return 0;
}