The Wheel of Fortune reminds you that the wheel is always turning and life is in a state of constant change. If you’re going through a difficult time right now, rest assured it can only get better from here and soon you will be blessed with good luck and good fortune. Similarly, if things are going amazingly well, know that this too will change and life may return to ’normal’ soon after. This is why it is so important to cherish the blissful moments in your life and make the most of them while they are within reach – because in a flash they could be gone.
Alice wants to make a wheel and decorate it with a circle of jewels. She has $n$ different jewels each of which can be colored in $m$ colors. The arrangement of Jewels always symbolizes fortune. Specifically, when the $i$-th jewel is colored with the $c_i$-th color, it is attached with $a_i$,$c_i$ amount of luck. After coloring all the $n$ jewels, she needs to arrange them in some order $k_1$, $k_2$, · · · , $k_n$(a permutation) such that no two adjacent jewels on the wheel are of the same color. Otherwise she may encounter disasters. Alice enjoys peaceful life and wants to find the minimum possible |max{$a_{k_i}$,$c_{k_i}$|1 ≤ $i$ ≤ $n$} - min{$a_{k_i}$,$c_{k_i}$|1 ≤ $i$ ≤ $n$}from all the valid arrangements.