SP7692 CHEM - Chemistry

Description

The story started some 5’000 years ago in Ancient Egypt, was continued by the Greeks and Arabs, reached France, Europe, and finally conquered the world. The studies on the compositions of waters, the humans’ greed for purified materials, millions of experiments and many brilliant minds made chemistry what it is today: No more the quest of the Philosopher’s stone, but the study of matter and the changes it undergoes. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP7692/e0faf5ad7ce58878c11487a52ba87a7b8acde85e.png) There remain nevertheless still groups of stout-hearted followers of ancient believes, so-called alchemist. Keeping their research top-secret, they meet once a year for a conference where they share their recent findings. This year’s location is Lausanne and Extremely Purified Fluorescent Liquids (EPFL) is the topic. The idea is that the chemists brew together some new EPFLs. As we speak about state of the art EPFLs, it is necessary that certain chemists put their very specific knowledge together. Thus for a certain EPFL _E $ _{1} $_ , the presence of chemists _C $ _{1} $_ , _C $ _{2} $_ and _C $ _{3} $_ may be required. For another _E $ _{2} $_ , chemists _C $ _{1} $_ $ _{} $ and _C $ _{4} $_ might be necessary. Although chemists are generally very patient people, as their reactions might take long times, they get very impatient if they are to observe experiments in which they are not involved. As an example, chemist _C $ _{4} $_ $ _{} $ would go crazy if he had to assist to the brewage of _E $ _{1} $_ . To ensure a pleasant stay in Lausanne to every chemist, you are to arrange their departure and arrival dates so that each chemist is available whenever his knowledge is required, but is not in Lausanne when other EPFLs are created. To this purpose, you are given a schedule with ones and zeros. Each column stands for one EPFL, each row for one chemist. There is a 1 at position (_C $ _{i} $ ,E $ _{i} $_ ) if chemist _C $ _{i} $_ is needed for EPFL _E $ _{i} $_ , and a zero otherwise. Your task boils now down on rearranging the columns in a way that all ones are consecutive in every line. For traditional reasons, the organizers’ EPFL is always brewed first and corresponds to the first column of the input schedule (_E $ _{1} $_ ). **INPUT** The input consists of several test-cases separated by an empty line. Each test-case starts with the number of chemists _C_ (1

Input Format

N/A

Output Format

N/A