1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>

using namespace std;

int main ()

{ 
  ios_base::sync_with_stdio(0);

  int ileZ, ile0, ile1, blad;
  float a, c, g, o;
  float ile0F, ile1F, ileZF;
  int ile0S, ile1S;
  string napis;
  string odkod;
  string slowo;
  int ktore;
  
  ile0=0;
  ile1=0;
  ile0S=0;
  ile1S=0;
  odkod="";
  a=0;
  c=0;
  g=0;
  o=0;
  blad=0;
  ktore=0;
  
  cin >> ileZ;
  cin >> napis;
  
  for (int n=0; n<napis.length(); n++)
	if (napis[n]=='0')
      ile0=ile0+1;
	else
	  ile1=ile1+1;
  
//  cout << ile0 << " " << ile1 << endl;
  
  ile0=ile0-ileZ;
  ile1=ile1-ileZ*2;
  
  ile0F=ile0;
  ile1F=ile1;
  ileZF=ileZ;
  
  for (int n=1; n<=ileZ; n++)
  {
    slowo=napis.substr((n-1)*8,8);
	ktore=ktore+1;
//cout << slowo << endl;
    for (int i=0; i<8; i++)
	{
      if (slowo[i]=='0')
        ile0S=ile0S+1;
	  else
	    ile1S=ile1S+1;
	}
//cout << ile0S << " " << ile1S << endl;	
      if ((ile0S == 5) and (ile1S == 3))
	    odkod=odkod+"a";
      else
      if ((ile0S == 4) and (ile1S == 4))
	    odkod=odkod+"c";
      else
      if ((ile0S == 3) and (ile1S == 5))
	    odkod=odkod+"g";
      else
      if ((ile0S == 2) and (ile1S == 6))
	    odkod=odkod+"o";
      else
        blad=1;
	
    ile0S=0;
	ile1S=0;
  }
  if (blad == 0)
    cout << odkod;
  
  if (blad == 1)
  {

  blad=0;
  odkod="";
  
//  cout << endl << "drugi";
  
  for (int n=0; n<=ileZ; n++)
  {
    o=n;
	c = 4*ile0F/10 + 2*ile1F/5 - 2*ileZF;
	g = -c/2 - ile0F/2 -3*o/2 + 2*ileZF;
	a = ileZF - 1*o - c - g;
	
//	cout << a << endl;
//	cout << c << endl;
//	cout << g << endl;
//	cout << o << endl;
//	cout << endl;

//   if ((a % ileZ == 0) and (c % ileZ == 0) and (g % ileZ == 0) and (o % ileZ == 0))
	if ((a-int(a) == 0) and (c-int(c) == 0) and (g-int(g) == 0) and (o-int(o) == 0) and (a >= 0) and (c >= 0) and (g >= 0) and (o >= 0) and ((a+c+g+o) == ileZF))
	{
      blad=1;
//	  cout << "T";
	  break;
    }	  

  }

  if (blad == 1)
  {
    for (int n=1; n<=a; n++)
      odkod=odkod+"a";
    for (int n=1; n<=c; n++)
      odkod=odkod+"c";
    for (int n=1; n<=g; n++)
      odkod=odkod+"g";
    for (int n=1; n<=o; n++)
      odkod=odkod+"o";
    cout << odkod;
  }
  else
	cout << "NIE";

  }
  
return 0;
}