
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main() {
  while(true) {
    char[] suffix, prefix;
    bool ans = true;
    auto n = readln.chomp;
    if (stdin.eof) break;
    if (n.to!(int) == 0) break;
    for(int i = 0; i < n.to!(int); i++) {
      string line = readln.chomp;
      if (line[0] == line[$ - 1]) {ans = false;}
      prefix ~= line[0];
      suffix ~= line[$ - 1];
    }
    if (!ans) {writeln("NG"); continue;}
    writeln(suffix.sort == prefix.sort ? "OK" : "NG");
  }
}