//* Problem  : 1552 - Scramble Sort
//* Contest  : acm.tju.edu.cn
//* Type     : Solution
//* Date     : 2007.07.31
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

int numbers[1000];
char strings[1000][1001];
char s[100000], st[1000];
char mask[1000];
int t;

char to_upper(char ch)
{
	if (ch >='a' && ch <='z') return ch-'a'+'A';
	return ch;
}

int cmpssstr(const void *a, const void *b)
{
	char *aa = (char*)a, *bb = (char*)b;
	int i = 0; char ch1, ch2;
	while (1)
	{
		ch1 = to_upper(aa[i]); ch2 = to_upper(bb[i]);
		if (!aa[i] || !bb[i])  break;
		if (ch1 != ch2) break;
		i++;
	}
	return (ch1 - ch2);
/*	return (strcmpi(aa, bb));*/
}	

int cmp_int(const void *a, const void *b)
{
	int *aa = (int*)a, *bb = (int*)b;
	return (aa[0] - bb[0]);
}


int main()
{
	int i, j;
	gets(s);
	int it = 0;
	while (strcmp(s, "."))
	{
printf("List #%d: ", ++it);
		int n_numbers = 0, n_strings = 0, inumbers = 0, i_strings = 0, imask = 0;
		char *str = s-1;
		while (1)
		{
			sscanf(str+1, "%s", st);
			st[strlen(st)-1] = 0;
			if (sscanf(st, "%i", &t) == 1) {numbers[n_numbers++] = t; mask[imask++] = 0;}
				else {strcpy(strings[n_strings++], st); mask[imask++] = 1;}
			str = strchr(str+1, ',');
			if (!str) break;
		}
		qsort(numbers, n_numbers, 4, cmp_int);
		qsort(strings, n_strings, sizeof(strings[0]), cmpssstr);
		if (mask[0] == 0) printf("%i", numbers[inumbers++]);
			else printf("%s", strings[i_strings++]);
		for (int i = 1; i < n_numbers + n_strings; i++)
			if (mask[i] == 0) printf(", %i", numbers[inumbers++]);
				else printf(", %s", strings[i_strings++]);
		printf(".\n");
		gets(s);
	}
}