Codeforces 270 Div1/2 Problem F

Can somebody explain the tutorial to problem F present here in more detail? What is meant by bases?
Can somebody share some related material?

//