A snowstorm hit the main road. There are m plows; plow i covers interval [ai,bi]. Intervals may overlap but none lies entirely inside another. They need not cover the whole road.
One operator runs every plow. Each time, pick the plow whose assigned interval still has the least uncovered length. Tie-break by smaller index. A road point needs clearing only once.
Line 1: n, m. Next m lines: ai, bi with increasing ai.
Print m lines: plow numbers in clearing order.