Autumn Trip
Time limit1sMemory limit128 MB
Decide whether an undirected graph contains a simple cycle that visits an even number of vertices.
Problem
With a beautiful autumn spreading out beyond the windows, Jakub and Alicja have decided to go on a trip. They plan to drive to some picturesque village, walk around the area for a while, and then return to the spot where they parked the car. Jakub does not want to disappoint Alicja, so the route of the trip has to be interesting.
A route is interesting when, apart from the starting point, it never passes through the same path or the same village more than once. On top of that, because Jakub is superstitious, the route must pass through an even number of villages.
In other words, given an area made of villages and the paths that connect them, decide whether there is a simple closed route that returns to the village it started from, repeats no village or path along the way, and passes through an even number of villages.
Input
The first line contains two integers: the number of villages () and the number of paths (), separated by a space.
Each of the next lines describes one path with two distinct integers and (), meaning there is a path that can be walked in both directions between the village numbered and the village numbered . No pair of villages appears more than once in the input.
Output
Print JEST on a single line if an interesting trip through an even number of villages exists, or BRAK otherwise.