def f u,a;u[a]=a==u[a]?a:f(u,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 u,b]=f u,a
}
puts u.map{|k,v|f u,v}.uniq[1]||h.any?{|k,v|v!=0}?:NG:"OK"
end