CF164A Variable, or There and Back Again
Description
Life is not easy for the perfectly common variable named Vasya. Wherever it goes, it is either assigned a value, or simply ignored, or is being used!
Vasya's life goes in states of a program. In each state, Vasya can either be used (for example, to calculate the value of another variable), or be assigned a value, or ignored. Between some states are directed (oriented) transitions.
A path is a sequence of states $ v_{1},v_{2},...,v_{x} $ , where for any $ 1
Input Format
The first line contains two space-separated integers $ n $ and $ m $ ( $ 1
Output Format
Print $ n $ integers $ r_{1},r_{2},...,r_{n} $ , separated by spaces or new lines. Number $ r_{i} $ should equal $ 1 $ , if Vasya's value in state $ i $ is interesting to the world and otherwise, it should equal $ 0 $ . The states are numbered from $ 1 $ to $ n $ in the order, in which they are described in the input.
Explanation/Hint
In the first sample the program states can be used to make the only path in which the value of Vasya interests the world, 1  2  3  4; it includes all the states, so in all of them Vasya's value is interesting to the world.
The second sample the only path in which Vasya's value is interesting to the world is , — 1  3; state 2 is not included there.
In the third sample we cannot make from the states any path in which the value of Vasya would be interesting to the world, so the value of Vasya is never interesting to the world.