Railroad
InterviewTime limit1sMemory limit1024 MB
Given X level junctions and Y switches, decide whether they can form a closed track using every piece with no dead ends.
Problem
Theta likes to play with her DUPLO railway set. The set has straight and curved pieces, Y-shaped switches, X-shaped level junctions, bridges that let one track cross over another, and straight railroad crossings that let car traffic cross.

Close-ups of some of the pieces are shown above.
To play, she picks a number of X-shaped level junctions and a number of Y-shaped switches and connects them with straight and curved pieces, using bridges as necessary.
The set has no bumpers, so she wants to build a closed track, like the examples in the manual:

Figure 1: Various track layouts possible with the DUPLO railway system. Curved pieces are shown in green, straights in red, switches in orange, level junctions in yellow, bridges in blue, and crossings in black. DUPLO is a trademark of the LEGO Group.
Sometimes this does not work with the number of X-shaped level junctions and Y-shaped switches she starts with. She quickly worked out exactly when a closed track is possible. Can you work it out too?
Write a program that outputs whether a railroad can be built without bumpers, that is, without any dead-end tracks.
Input
The input is a single test case with two integers () and (), the number of X-shaped level junctions and Y-shaped switches.
Output
Output possible if she can build a closed track that uses all level junctions and all switches without any dead ends, or impossible otherwise.