
require 'pp'

loop do
  prefix = [];
  suffix = [];
  ans = true;
  n = $stdin.gets.chomp.to_i
  break if n == 0
  n.times do
    line = $stdin.gets.chomp
    prefix.push(line[0]);
    suffix.push(line[-1]);
  end
  puts (prefix.sort == suffix.sort) ? "OK" : "NG"
end