C program to solve the word-rectangle problem