#include <stdio.h>

#define TRUE 1																												/* ?????????*/
#define FALSE 0																												/* ?????????*/
#define LOOP_INIT 0																											/* ??????????????????*/
#define ARRAY_INIT 0																										/* ???????????????*/
#define CARD_ARRAY_MAX 36																									/* ??????????????§?????°*/
#define EXIT_SUCCESS 0																										/* ??£????????????????????????*/
#define PREV_ITEM( x ) x - 1																								/* 1?????????????´?*/

int main( void )
{
	unsigned char ubW_Dcard_cnt;																							/* ???????????°*/
	unsigned char aubW_Dbubble_mark[ CARD_ARRAY_MAX ] = { ARRAY_INIT };														/* ????????????????????¨?¨??????????*/
	unsigned char aubW_Dbubble_num[ CARD_ARRAY_MAX ] = { ARRAY_INIT };														/* ????????????????????¨??°?????????*/
	unsigned char aubW_Dselect_mark[ CARD_ARRAY_MAX ] = { ARRAY_INIT };														/* ?????????????????¨?¨??????????*/
	unsigned char aubW_Dselect_num[ CARD_ARRAY_MAX ] = { ARRAY_INIT };														/* ?????????????????¨??°?????????*/
	unsigned char ubW_Dtrade_mark;																							/* ?¨????????????¨?????°*/
	unsigned char ubW_Dtrade_num;																							/* ??°???????????¨?????°*/
	unsigned char ubW_Dcard_min;																							/* ????°?????´????????´???????(??????????????????????????¨)*/
	unsigned char ubW_Cloop_cnt;																							/* 1????±????????????????????????????*/
	unsigned char ubW_Cloop_cnt_sub;																						/* 2????±????????????????????????????*/
	unsigned char ubW_Fstable_flug = TRUE;																					/* ????????????????????°*/

	scanf( "%d", &ubW_Dcard_cnt );																							/* ???????????°???????????????*/
	/* ??\?????¨????????? */
	for( ubW_Cloop_cnt = LOOP_INIT; ubW_Cloop_cnt < ubW_Dcard_cnt; ubW_Cloop_cnt++ ){
		scanf( " %c%d", &aubW_Dbubble_mark[ ubW_Cloop_cnt ], &aubW_Dbubble_num[ ubW_Cloop_cnt ] );							/* ?????????????¨?????????°??????????????????*/
		aubW_Dselect_mark[ ubW_Cloop_cnt ] = aubW_Dbubble_mark[ ubW_Cloop_cnt ];											/* ?????????????????¨?????\??????????¨???????????£?*/
		aubW_Dselect_num[ ubW_Cloop_cnt ] = aubW_Dbubble_num[ ubW_Cloop_cnt ];												/* ?????????????????¨?????\???????????°??????????£?*/
	}/* ??\?????¨?????????????????? */

	/* ?????????????????? */
	/* ?????????????±??????´????????? */
	for( ubW_Cloop_cnt = LOOP_INIT; ubW_Cloop_cnt < ubW_Dcard_cnt; ubW_Cloop_cnt++ ){
		/* ????????¨????????? */
		for( ubW_Cloop_cnt_sub = PREV_ITEM( ubW_Dcard_cnt ); ubW_Cloop_cnt_sub > ubW_Cloop_cnt; ubW_Cloop_cnt_sub-- ){
			/* 1?????????????´?????????¨???????´?????????§????????´??? */
			if( aubW_Dbubble_num[ ubW_Cloop_cnt_sub ] < aubW_Dbubble_num[ PREV_ITEM( ubW_Cloop_cnt_sub ) ] ){
				ubW_Dtrade_mark = aubW_Dbubble_mark[ ubW_Cloop_cnt_sub ];													/* ?¨????????????¨?????°????????¨???????´??????????*/
				ubW_Dtrade_num = aubW_Dbubble_num[ ubW_Cloop_cnt_sub ];														/* ??°???????????¨?????°????????¨???????´??????????*/

				aubW_Dbubble_mark[ ubW_Cloop_cnt_sub ] = aubW_Dbubble_mark[ PREV_ITEM( ubW_Cloop_cnt_sub ) ];				/* ?????¨???????´????1?????????????´?????????????(?¨????)*/
				aubW_Dbubble_num[ ubW_Cloop_cnt_sub ] = aubW_Dbubble_num[ PREV_ITEM( ubW_Cloop_cnt_sub ) ];					/* ?????¨???????´????1?????????????´?????????????(??°???)*/

				aubW_Dbubble_mark[ PREV_ITEM( ubW_Cloop_cnt_sub ) ] = ubW_Dtrade_mark;										/* 1?????????????´?????????¨???????´?????????????(?¨????)*/
				aubW_Dbubble_num[ PREV_ITEM( ubW_Cloop_cnt_sub ) ] = ubW_Dtrade_num;										/* 1?????????????´?????????¨???????´?????????????(??°???)*/
			}
			else{
				/* else?????????????????????????????\ */
			}
		}/* ????????¨?????????????????? */
	}/* ?????????????±??????´?????????????????? */
	/* ??????????????????????????? */

	/* ??????????????? */
	/* ?????????????±??????´????????? */
	for( ubW_Cloop_cnt = LOOP_INIT; ubW_Cloop_cnt < ubW_Dcard_cnt; ubW_Cloop_cnt++ ){
		ubW_Dcard_min = ubW_Cloop_cnt;																						/* ?????????????±?????¨????*/
		/* ????????¨????????? */
		for( ubW_Cloop_cnt_sub = ubW_Cloop_cnt; ubW_Cloop_cnt_sub < ubW_Dcard_cnt; ubW_Cloop_cnt_sub++ ){
			/* ??????????±?????????????????±????????°?????????´??? */
			if( aubW_Dselect_num[ ubW_Cloop_cnt_sub ] < aubW_Dselect_num[ ubW_Dcard_min ] ){
				ubW_Dcard_min = ubW_Cloop_cnt_sub;																			/* ????°?????´????????´????????????´??°*/
			}
			else{
				/* else?????????????????????????????\ */
			}
		}/* ????????¨?????????????????? */
		/* ?????????????±????????°?????´???§???????????´??? */
		if( ubW_Cloop_cnt != ubW_Dcard_min ){
			ubW_Dtrade_mark = aubW_Dselect_mark[ ubW_Cloop_cnt ];															/* ?¨????????????¨?????°????????¨???????´??????????*/
			ubW_Dtrade_num = aubW_Dselect_num[ ubW_Cloop_cnt ];																/* ??°???????????¨?????°????????¨???????´??????????*/

			aubW_Dselect_mark[ ubW_Cloop_cnt ] = aubW_Dselect_mark[ ubW_Dcard_min ];										/* ?????¨???????´????1?????????????´?????????????(?¨????)*/
			aubW_Dselect_num[ ubW_Cloop_cnt ] = aubW_Dselect_num[ ubW_Dcard_min ];											/* ?????¨???????´????1?????????????´?????????????(??°???)*/

			aubW_Dselect_mark[ ubW_Dcard_min ] = ubW_Dtrade_mark;															/* 1?????????????´?????????¨???????´?????????????(?¨????)*/
			aubW_Dselect_num[ ubW_Dcard_min ] = ubW_Dtrade_num;																/* 1?????????????´?????????¨???????´?????????????(??°???)*/
		}
		else{
			/* else?????????????????????????????\ */
		}
	}/* ?????????????±??????´????????? */
	/* ???????????????????????? */

	/* ???????????\??¨????????? */
	for( ubW_Cloop_cnt = LOOP_INIT; ubW_Cloop_cnt < ubW_Dcard_cnt; ubW_Cloop_cnt++ ){
		/* ?????????????????????????????¨????????????????????????????????´???????????£?????´??? */
		if( aubW_Dbubble_mark[ ubW_Cloop_cnt ] != aubW_Dselect_mark[ ubW_Cloop_cnt ] ){
			ubW_Fstable_flug = FALSE;																						/* ????????°???FALSE???*/
		}
		else{
			/* else?????????????????????????????\ */
		}
	}/* ???????????\??¨?????????????????? */

	/* ????????????????????????????????¨????????? */
	for( ubW_Cloop_cnt = LOOP_INIT; ubW_Cloop_cnt < PREV_ITEM( ubW_Dcard_cnt ); ubW_Cloop_cnt++ ){
		printf( "%c%d ", aubW_Dbubble_mark[ ubW_Cloop_cnt ], aubW_Dbubble_num[ ubW_Cloop_cnt ] );							/* ????´???°-1?????§???????´??????????*/
	}/* ????????????????????????????????¨?????????????????? */
	printf( "%c%d\n", aubW_Dbubble_mark[ PREV_ITEM( ubW_Dcard_cnt ) ], aubW_Dbubble_num[ PREV_ITEM( ubW_Dcard_cnt ) ] );	/* ?????????????´???????????????????*/
	printf("Stable\n");																										/* ??????????????????????????????????????????????????§Stable??¨??????*/

	/* ?????????????????????????????¨????????? */
	for( ubW_Cloop_cnt = LOOP_INIT; ubW_Cloop_cnt < PREV_ITEM( ubW_Dcard_cnt ); ubW_Cloop_cnt++ ){
		printf( "%c%d ", aubW_Dselect_mark[ ubW_Cloop_cnt ], aubW_Dselect_num[ ubW_Cloop_cnt ]);							/* ????´???°-1?????§???????´??????????*/
	}/* ?????????????????????????????¨?????????????????? */
	printf( "%c%d\n", aubW_Dselect_mark[ PREV_ITEM( ubW_Dcard_cnt ) ], aubW_Dselect_num[ PREV_ITEM( ubW_Dcard_cnt ) ]);		/* ?????????????´???????????????????*/
	/* ?????????????????????????????¨????????????????????????????????´???????????£?????´??? */
	if( ubW_Fstable_flug == FALSE ){
		printf( "Not stable\n" );																							/* ????????????????????????????????????????????§Not stable??¨??????*/
	}
	else{
		printf( "Stable\n" );																								/* ?????????????????????????????????????????§Stable??¨??????*/
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 608