Under construction

Still being built. Things may change

Railroad

Interview

Time limit1sMemory limit1024 MB

Summary
Given X level junctions and Y switches, decide whether they can form a closed track using every piece with no dead ends.
Level

Easy3 of 10

Topics
Math, Graph
Solved
No attempts yet

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 XX (0≤X≤10000 \le X \le 1000) and YY (0≤Y≤10000 \le Y \le 1000), 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.

Examples3

  1. Example 1

    Input
    1 0
    
    Expected output
    possible
    
  2. Example 2

    Input
    0 2
    
    Expected output
    possible
    
  3. Example 3

    Input
    1 3
    
    Expected output
    impossible