UPDATE: My description of the output is wrong! I cannot figure out the real requirement.