#include <iostream>
#include <type_traits>
#include <vector>
#include <cstdint>
#include <algorithm>
#include <list>
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0086"

using i32   = int32_t;
using i64   = int64_t;
using u32   = uint32_t;
using u64   = uint64_t;
using uint  = unsigned int;
using usize = std::size_t;
using ll    = long long;
using ull   = unsigned long long;
using ld    = long double;
template<typename T, usize n>
using arr = T (&)[n];
template<typename T, usize n>
using c_arr = const T (&)[n];
template<typename T>
T in()
{
    T v;
    return std::cin >> v, v;
}
template<typename T, typename Uint, usize n, usize i>
T in_v(typename std::enable_if<(i == n), c_arr<Uint, n>>::type) { return in<T>(); }
template<typename T, typename Uint, usize n, usize i>
auto in_v(typename std::enable_if<(i < n), c_arr<Uint, n>>::type& szs)
{
    const usize s = (usize)szs[i];
    std::vector<decltype(in_v<T, Uint, n, i + 1>(szs))> ans(s);
    for (usize j = 0; j < s; j++) { ans[j] = in_v<T, Uint, n, i + 1>(szs); }
    return ans;
}
template<typename T, typename Uint, usize n>
auto in_v(c_arr<Uint, n> szs) { return in_v<T, Uint, n, 0>(szs); }
template<typename... Types>
auto in_t() { return std::tuple<std::decay_t<Types>...>{in<Types>()...}; }

template<typename T>
int out(const T& v) { return std::cout << v, 0; }
template<typename T>
int out(const std::vector<T>& v)
{
    for (usize i = 0; i < v.size(); i++) {
        if (i > 0) { std::cout << ' '; }
        out(v[i]);
    }
    return std::cout << "\n", 0;
}
template<typename T1, typename T2>
int out(const std::pair<T1, T2>& v) { return out(v.first), std::cout << ' ', out(v.second), 0; }
template<typename T, typename... Args>
int out(const T& v, const Args... args) { return out(v), std::cout << ' ', out(args...), 0; }
template<typename... Args>
int outln(const Args... args) { return out(args...), std::cout << '\n', 0; }
template<typename... Args>
void outel(const Args... args) { return out(args...), std::cout << std::endl, 0; }

class euler_trail
{
private:
    const usize sz;
    struct edge
    {
        edge() : to{0}, rev{} {}
        edge(const usize to, const std::list<edge>::iterator& rev) : to{to}, rev{rev} {}
        usize to;
        std::list<edge>::iterator rev;
    };
    std::vector<usize> dm;
    std::vector<std::list<edge>> edges;

public:
    euler_trail(const usize sz) : sz{sz}, dm(sz, 0), edges(sz) {}
    void add_edge(const usize s, const usize t)
    {
        edges[t].emplace_front(s, edges[s].begin());
        if (s != t) { edges[s].emplace_front(t, edges[t].begin()), edges[t].front().rev = edges[s].begin(); }
        dm[t]++, dm[s]++;
    }
    usize start_pos() const
    {
        std::vector<usize> ans;
        for (usize i = 0; i < sz; i++) {
            if (dm[i] % 2 == 1) { ans.push_back(i); }
        }
        return ans.size() == 2 ? ans.front() : sz - 1;
    }
    std::vector<usize> trail_from(const usize s)
    {
        std::vector<usize> ans;
        auto dfs = [&](auto&& self, const usize s) -> void {
            while (not edges[s].empty()) {
                auto it        = edges[s].begin();
                const usize to = it->to;
                if (s != to) { edges[to].erase(it->rev); }
                edges[s].erase(it), self(self, to);
            }
            ans.push_back(s);
        };
        dfs(dfs, s);
        std::reverse(ans.begin(), ans.end());
        return ans;
    }
};
int main()
{
    while (true) {
        constexpr usize N = 100;
        euler_trail et(N);
        std::vector<usize> dim(N, 0);
        usize e = 0;
        while (true) {
            const auto a = in<usize>();
            const auto b = in<usize>();
            if (std::cin.eof()) { break; }
            if (a == 0 and b == 0) { break; }
            et.add_edge(a - 1, b - 1);
            dim[a - 1]++, dim[b - 1]++;
            e++;
        };
        if (std::cin.eof()) { break; }
        bool ok = true;
        if (dim[0] % 2 == 0 or dim[1] % 2 == 0) { ok = false; }
        for (usize i = 2; i < N; i++) {
            if (dim[i] % 2 == 1) { ok = false; }
        }
        if (not ok) {
            outln("NG");
            continue;
        }
        const auto ans = et.trail_from(0);
        if (ans.back() == 1 and ans.size() == e + 1) {
            outln("OK");
        } else {
            outln("NG");
        }
    };
    return 0;
}



Measured memory_bytes: 3116