def f a;a==$u[a]?a:$u[a]=f($u[a])end
while 0<n=gets.to_i
$u={}
h=Hash.new{|i,k|$u[k]=k;i[k]=0}
n.times{
h[a=gets[0]]+=1
h[b=$_[-2]]-=1
$u[f b]=f a
}
puts $u.map{|k,v|f v}.uniq[1]||h.any?{|k,v|v!=0}?:NG:"OK"
end