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 1:
    t = int(input())
    if t == 0: break
    n = int(input())
    i = 0
    sum = 0
    while i < n:
        s, f = map(int, input().split())
        a = f - s
        sum = sum + a
        i += 1
    if sum < t:
        print(t - sum)
    else:
        print("OK")

Python: # AOJ 0238 Time to Study
# Python3 2018.6.25 bal4u

while 1:
	t = int(input())
	if t == 0: break
	n = int(input())
	sm = 0
	for i in range(n):
		s, f = map(int, input().split())
		sm += f-s
	print("OK" if sm >= t else t - sm)

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

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

Python: # AOJ 0238 Time to Study
# Python3 2018.6.25 bal4u
 
while 1:
    t = int(input())
    if t == 0: break
    n = int(input())
    sm = 0
    for i in range(n):
        s, f = map(int, input().split())
        sm += f-s
    print("OK" if sm >= t else t - sm)

Python: while True:
    try:
        t=int(input())
        n=int(input())
        M=0
        for i in range(n):
            s,f=map(int,input().split())
            A=f-s
            M=M+A
        if t>M:
            print(t-M)
        else:
            print("OK")
    except:
        break

Python: while True:
  t=int(input())
  if t == 0: break
  n = int(input())
  for i in range(n):
    s,f=map(int,input().split())
    t-=f-s
  if t<1:
    print("OK")
  else:
    print(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;
    
    }

}