Algorithm


B. Mammoth's Genome Decoding
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The process of mammoth's genome decoding in Berland comes to its end!

One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.

It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.

Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.

Input

The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome.

The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.

Output

If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).

Examples
input
Copy
8
AG?C??CT
output
Copy
AGACGTCT
input
Copy
4
AGCT
output
Copy
AGCT
input
Copy
6
????G?
output
Copy
===
input
Copy
4
AA??
output
Copy
===
Note

In the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.

In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.

In the third and the fourth examples it is impossible to decode the genom.

 



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
    int n, a = 0, g = 0, c = 0, t = 0;
    cin >> n;
    string s;
    cin >> s;
    
    if(n % 4 != 0) {
        cout << "===" << endl;
        return 0;
    }
    
    for(int i = 0; i < n; i++) {
        if(s[i] == 'A')
            a++;
        else if(s[i] == 'G')
            g++;
        else if(s[i] == 'C')
            c++;
        else if(s[i] == 'T')
            t++;
    }
    
    n /= 4;
    
    if(a <= n && g <= n && c <= n && t <= n) {
        a = abs(a - n);
        g = abs(g - n);
        c = abs(c - n);
        t = abs(t - n);
        
        for(int i = 0; i < s.size(); i++) {
            if(s[i] == '?') {
                if(a) {
                    cout << 'A';
                    a--;
                } else if(g) {
                    cout << 'G';
                    g--;
                } else if(c) {
                    cout << 'C';
                    c--;
                } else if(t) {
                    cout << 'T';
                    t--;
                }
            } else
                cout << s[i];
        }
        
        cout << endl;
    } else
        cout << "===" << endl;
    
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
8
AG?C??CT

Output

x
+
cmd
AGACGTCT
Advertisements

Demonstration


Codeforces Solution-Mammoth's Genome Decoding-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+