1 #include<cstdio>
2 #include<iostream>
3 #include<stack>
4 using namespace std;
5 int main()
6 {
7 int n,now=1,i,chu[30],cnt=1,size=0;
8 char k;
9 stack<int>station;
10 cin>>n;
11 while(n--)
12 {
13 cin>>k;
14 if(k=='A')
15 {
16 chu[cnt++]=now++;
17 }
18 if(k=='B')
19 {
20 if(size==5)
21 {
22 cout<<"No"<<endl;
23 return 0;
24 }
25 size++;
26 station.push(now++);
27 }
28 if(k=='C')
29 {
30 if(station.empty())
31 {
32 cout<<"No"<<endl;
33 return 0;
34 }
35 chu[cnt++]=station.top();
36 station.pop();
37 size--;
38 }
39 }
40 cout<<"Yes"<<endl;
41 for(i=1;i<=cnt-1;i++)
42 cout<<chu[i]<<endl;
43 return 0;
44 }