There is a simple graph with an even number of edges. You are to define if it is possible to present it by the set of pairs of adjacent edges (having a common vertex).
contains a non-empty sequence of the integers pairs. The length of the sequence is even and is from 2 to 1050. Each pair of integers denotes vertices identifiers of one edge. All the identifiers are from 1 to 1000. You may assume that there are no loops and multiple edges in the graph defined by the input data.
“1” (without quotation marks), if the decomposition is possible and “0” otherwise.
Problem Author: Idea: Alexander Petrov, prepared by Alexander Petrov, Leonid Volkov
Problem Source: VIII Collegiate Students Urals Programming Contest. Yekaterinburg, March 11-16, 2004