read editorial and solve this later.