#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a,b;
	while(cin>>a>>b){
		map<int,vector<int> >in;
		in[a].pb(b);
		in[b].pb(a);
		while(cin>>a>>b,a||b){
			in[a].pb(b);
			in[b].pb(a);
		}
		bool h=true;
		for(map<int,vector<int> >::iterator it=in.begin();it!=in.end();it++){
			int d=it->first;
			cout<<d<<" "<<in[d].size()<<endl;
			if(!(d==1||d==2)&&in[d].size()%2){h=false;break;}
			else if((d==1||d==2)&&in[d].size()%2==0){h=false;break;}
			
		}
		if(h)cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
	}
}