Assume books are M1,M2,M3,M3,C1,C2,C3,H1.H2,H3,L1
Now assume that i need a permutations of above word where I want all M prefixes alphabet together ,All C prefixes alphabet together ,All H prefixes alphabet together,All L prefixes words together.
So if something is together consider it as a word.So i can say I need a permutation of a word MCHL,M means all M1,M2,M3,M4.Same for others.
So i can have 4! permutations of MCHL . Now the M itself has 4 objects M1,M2,M3,M4 which can permute in 4! ways,Similarly C,H,L can permute among themselves.
So toal answer will be 4!*(4!*3!*2!*1!) = 6912 should be the correct answer