#include<bits/stdc++.h>
using namespace std;
struct node{
bool endmark;
int cnt_trees;
node *next[11];
node(){
endmark=false;
cnt_trees=0;
for(int i=0;i<11;i++) next[i]=NULL;
}
}*root;
bool insert_into_Trie(string str){
node *cur=root;
for(int i=0;str[i];i++){
int id=str[i]-'a';
if(i==(str.size())-1 && cur->next[id]!=NULL ) return false;
if(cur->next[id]==NULL)
cur->next[id]=new node();
cur=cur->next[id];
if(cur->endmark) return false;
}
cur->endmark=true;
return true;
}
int main()
{
int n,f=1;
string str,bad;
bool ok=true;
cin>>n;
root=new node();
while(n--){
cin>>str;
if(!ok) continue;
ok=insert_into_Trie(str);
if(!ok) bad=str;
}
if(ok) cout<<"GOOD SET\n";
else cout<<"BAD SET\n"<<bad<<endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RydWN0IG5vZGV7CiAgICBib29sIGVuZG1hcms7CiAgICBpbnQgY250X3RyZWVzOwogICAgbm9kZSAqbmV4dFsxMV07CiAgICBub2RlKCl7CiAgICAgICAgZW5kbWFyaz1mYWxzZTsKICAgICAgICBjbnRfdHJlZXM9MDsKICAgICAgICBmb3IoaW50IGk9MDtpPDExO2krKykgbmV4dFtpXT1OVUxMOwogICAgfQp9KnJvb3Q7Cgpib29sIGluc2VydF9pbnRvX1RyaWUoc3RyaW5nIHN0cil7CiAgICBub2RlICpjdXI9cm9vdDsKICAgIGZvcihpbnQgaT0wO3N0cltpXTtpKyspewogICAgICAgIGludCBpZD1zdHJbaV0tJ2EnOwogICAgICAgIGlmKGk9PShzdHIuc2l6ZSgpKS0xICYmIGN1ci0+bmV4dFtpZF0hPU5VTEwgKSByZXR1cm4gZmFsc2U7CiAgICAgICAgaWYoY3VyLT5uZXh0W2lkXT09TlVMTCkKICAgICAgICAgICAgY3VyLT5uZXh0W2lkXT1uZXcgbm9kZSgpOwogICAgICAgICAgICBjdXI9Y3VyLT5uZXh0W2lkXTsKICAgICAgICAgICAgaWYoY3VyLT5lbmRtYXJrKSByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBjdXItPmVuZG1hcms9dHJ1ZTsKICAgIHJldHVybiB0cnVlOwp9CgppbnQgbWFpbigpCnsKICAgIGludCBuLGY9MTsKICAgIHN0cmluZyBzdHIsYmFkOwogICAgYm9vbCBvaz10cnVlOwogICAgY2luPj5uOwogICAgcm9vdD1uZXcgbm9kZSgpOwogICAgd2hpbGUobi0tKXsKICAgICAgICBjaW4+PnN0cjsKICAgICAgICBpZighb2spIGNvbnRpbnVlOwogICAgICAgIG9rPWluc2VydF9pbnRvX1RyaWUoc3RyKTsKICAgICAgICBpZighb2spIGJhZD1zdHI7CiAgICB9CiAgICBpZihvaykgY291dDw8IkdPT0QgU0VUXG4iOwogICAgZWxzZSBjb3V0PDwiQkFEIFNFVFxuIjw8YmFkPDxlbmRsOwogICAgcmV0dXJuIDA7Cn0K