#include using namespace std; int main() { int N, M; cin >> N >> M; string Ans; vector Win(N); vector S(N); for (string &T : S) cin >> T; for (int i = 0; i < M; i++) { char Hand = 'G'; int GCP = 0; for (int j = 0; j < N; j++) { if (Win.at(j)) continue; if (S.at(j).at(i) == 'G') GCP |= 1; if (S.at(j).at(i) == 'C') GCP |= 2; if (S.at(j).at(i) == 'P') GCP |= 4; } if (GCP == 1) Hand = 'P'; if (GCP == 2) Hand = 'G'; if (GCP == 3) Hand = 'G'; if (GCP == 4) Hand = 'C'; if (GCP == 5) Hand = 'P'; if (GCP == 6) Hand = 'C'; if (GCP == 7) break; for (int j = 0; j < N; j++) { if (Hand == 'G' && S.at(j).at(i) == 'C') Win.at(j) = true; if (Hand == 'C' && S.at(j).at(i) == 'P') Win.at(j) = true; if (Hand == 'P' && S.at(j).at(i) == 'G') Win.at(j) = true; } Ans += Hand; } cout << (all_of(Win.begin(), Win.end(), [](bool ok) { return ok; }) ? Ans : "-1") << endl; }