#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int n, m, s, t = 0;
int d[110][110], used[110];

/*v????????¨??°???t????¨?????????????????????°*/
bool solve(int v,int count) {
	if (used[v] == 0) {
		used[v] == 1; count++;
	}
	printf("%d", v);
	if (d[2][v] > 0 || d[v][2] > 0 && count == t - 1)return true;
	for (int u = 3; u <= t; u++) {
		if (v <= u&&d[v][u]>0) {
			d[v][u]--; if (solve(u, count)) return true;
		}
		else if (v > u&&d[u][v] > 0 ) {
			d[u][v]--; if (solve(u, count))return true;
			}
		}
	return false;
}

int main() {
	for (int i = 0; i < 110; i++) {
		used[110] = 0;
		for (int j = 0; j < 110; j++) {
			d[i][j] = 0;
		}
	}
	while (scanf_s("%d %d", &n, &m)) {
		if (n == 0 && m == 0)break;
		s = max(n, m);
		t = max(t, s);
		d[min(n, m)][s]++;
	}
	
	if (solve(1,1))printf("OK\n");
	else printf("NG\n");
}