//DFS(TLEかな) #include #include #include #include using namespace std; using namespace atcoder; using ll = long long; //#define endl "\n"; ll N, M, chk[100009]; string S[100009]; vector ans; vector te = {'G', 'C', 'P'}; set rest; void dfs(ll pos){ if(pos == M){ if(rest.size() == 0){ for(auto s: ans) cout << s; cout << endl; exit(0); }else{ return; } } vector visited(3, true); for(int k = 0; k < 3; k++){ for(auto itr = rest.begin(); itr != rest.end(); ++itr){ if(S[*itr][pos] == te[(k + 2) % 3]){ visited[k] = false; } } if(visited[k]){ vector tmp; for(auto itr = rest.begin(); itr != rest.end(); ++itr){ if(S[*itr][pos] == te[(k + 1) % 3]){ tmp.push_back(*itr); } } ans.push_back(te[k]); for(auto p: tmp) rest.erase(p); dfs(pos + 1); for(auto p: tmp) rest.insert(p); ans.pop_back(); } } } int main(){ cin >> N >> M; for(int i = 0; i < N; i++){ cin >> S[i]; rest.insert(i); } dfs(0); cout << -1 << endl; return 0; }