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

int c = 0;

void foo(char *s1, char *s2, int n) {
	int j;
	if (*s1 == '\0') {
		c++;
		if (c == 36690094) {
			printf("foo %03d %s\n", c, s2);
			exit(0);
		}
	} else {
		for (j = 0; j < n; j++) {
			if (s2[j] == '\0') {
				s2[j] = *s1;
				foo(s1 + 1, s2, n);
				s2[j] = '\0';
			}
		}
	}
}

int main(void) {
	
	char str1[] = "ABCDEFGHIJKLMNO";
	char str2[sizeof(str1)] = {0};
	
	foo(str1, str2, (int)strlen(str1));
	
	
	return 0;
}
