#include <bits/stdc++.h>
using namespace std;

struct Graph {
  int n;
  struct edge { int src, dst, rev; };
  vector<vector<edge>> adj;
  Graph() : n(0) {}

  void addEdge(int src, int dst) {
    n = max(n, max(src, dst)+1);
    if (adj.size() < n) adj.resize(n);
    adj[src].push_back({src, dst, (int)adj[dst].size()});
    adj[dst].push_back({dst, src, (int)adj[src].size()-1});
  }

  bool eulerianPath() {
    int m = 0, s = -1;
    if (adj[0].size() % 2 == 0 || adj[1].size() % 2 == 0) return false;
    for (int u = 2; u < n; ++u) {
      if (adj[u].size() % 2 == 1) return false;;
    }
    return true;
  }
};

int main() {
  int a, b;
  while (cin >> a >> b) {
    Graph g;
    while (1) {
      g.addEdge(a-1, b-1);
      if (cin >> a >> b, a) continue;
      break;
    }
    cout << ( (g.eulerianPath()) ? "OK" : "NG" ) << endl;
  }
  return 0;
}

