#include <stdio.h>
#include <string.h>

int heading_length(const char heading_char) {
	int c;
	unsigned int i = 0;
	while ((c = getchar()) == heading_char) {
		i++;
	}
	if (c != EOF) {
		ungetc(c, stdin);
		return i;
	} else {
		return -1;
	}
}

void print_section(unsigned int* section_arr, int level) {
	for (int i = 0; i <= level; i++) {
		printf("%u.", section_arr[i]);
	}
	printf("%u)", section_arr[level + 1]);
}

int main(int argc, const char** argv) {
	char sect;

	if (argc == 1) {
		sect = '*';
	} else if (argc == 3 && !strcmp(argv[1], "-c")) {
		sect = argv[2][0];
	} else {
		printf("Usage: %s [-c {symbol}]\n", argv[0]);
		return 1;
	}


	int level = 0;
	unsigned int sections[] = { 0, 0, 0, 0, 0, 0, 0, 0 };

	int begin_of_line = 1;
	int c;

	while ((c = getchar()) != EOF) {
		if (!begin_of_line) {
			putchar(c);
			while ((c = getchar()) != '\n' && c != EOF)
				putchar(c);
			if (c == EOF) break;
			putchar('\n');
			begin_of_line = 1;
		} else {
			int n = heading_length(sect);
			if (n > 8) {
				n = 8;
			}

			begin_of_line = 0;
			if (n == -1) break;
			if (n == 0) continue;

			n--;

			if (level == n) {
				sections[level]++;
			} else if (n > level) {
				for (int i = level + 1; i < n; i++)
					sections[i] = 0;
				sections[n] = 1;
				level = n;
			} else {
				sections[n]++;
				level = n;
			}

			print_section(sections, level);

		}
	}

	return 0;
}
