Note that time limit has been increased to 3 sec
Mike has 3 arrays a,b,c of length n and a number k. He wants to find minimal value of
maxni=1(((ai+t)modk)+((bi+t)modk)+((ci+t)modk))
over all non-negative integer values of t.
Input
The first line contains two numbers n and k (1≤n≤3×105,1≤k≤108).
Each of the next n lines contains 3 numbers - ai,bi,ci (0≤ai,bi,ci<k).
Output
Output the minimal value achievable.
For t=4 we have that and this is the minimal value we chan achieve.