#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() constexpr ll MOD=1000000007; constexpr ll INF=2e18; int main(){ int n; cin >> n; string s; cin >> s; REP(i,n){ if(s[i]!='Q'){ cout << -1 << endl; return 0; } } int m=sqrt(n); if(m*m==n){ REP(i,m) cout << 'Q'; cout << endl; } else{ cout << -1 << endl; } return 0; }