#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<queue>
using namespace std;
const int N=10;
int k=0,wan_neng=0,cnt=0;
int a[N];
unordered_map<string,int>mp{{"A",1},{"2",2},{"3",3},
{"4",4},{"5",5},{"6",6},
{"7",7},{"8",8},{"9",9},
{"10",10},{"J",11},{"Q",12},
{"K",13},{"BQ",0},{"SQ",0}};
int main()
{
priority_queue<int,vector<int>,greater<int>> q;
for(int i=0;i<5;i++)
{
string s;
cin>>s;
q.push(mp[s]);
}
while(!q.empty())
{
auto t=q.top();
q.pop();
if(t!=0) a[k++]=t;
else wan_neng++;
}
for(int i=0;i<k;i++)//输出除了 大小王 以外的序列
{
cout<<a[i]<<" ";
}
cout<<endl;
for(int i=0,j=1;i<k;i++,j++)
{
if(a[i]==a[j]-1)
{
cnt++;
continue;
}
else if(a[i]!=a[j]-1)//加入 大小王 尝试调整
{
if(wan_neng!=0)
{
for(int m=k;m>=j;m--)
{
a[m+1]=a[m];
}
a[j]=a[i]+1;
wan_neng--;
k++;//表长+1
cnt++;
}
else break;
}
}
for(int i=0;i<k;i++)//输出加入 大小王 后的序列
{
cout<<a[i]<<" ";
}
cout<<endl;
cout<<cnt<<endl;
if(cnt==4) cout<<"YES"<<endl;//cnt满足4即可说明有序
else cout<<"NO"<<endl;
return 0;
}
-------------------------------
9 10 BQ SQ 11
-------------------------------
9 10
9 10 11 12 13
4
YES
--------------------------------
A 2 BQ SQ J
--------------------------------
1 2 11
1 2 3 4 11
3
NO