Tic-tac-toe P54928


Statement
 

pdf   zip

thehtml

In the tic-tac-toe game, two players compete to be the first to place in a board 3 × 3 three pieces forming a vertical, horizontal or diagonal line. A player places white pieces, the other one uses black pieces always taking turns. Starts the player with the white pieces. The game ends when one of the payers reach to place three pieces forming a line, or when the nine positions are taken.

Your task is to write a program that indicates if a given configurations of a tic-tac-toe game is correct or not. That is, it must indicate if the configuration could be obtained in a game playing according to the rules.

Input

The input consists of three line with three chacteres each one. A ’W’ indicates a white piece. A ’B’ indicates a black piece. A dot indicates an empty position.

Output

Your program must print "possible" or "impossible" as required.

Public test cases
  • Input

    WWB
    ..B
    WB.
    

    Output

    possible
    
  • Input

    W..
    ...
    ..W
    

    Output

    impossible
    
  • Input

    B.B
    W.W
    BWB
    

    Output

    impossible
    
  • Input

    WWW
    ..B
    BB.
    

    Output

    impossible
    
  • Input

    ..B
    WBW
    BWW
    

    Output

    impossible
    
  • Input

    WWW
    ...
    BBB
    

    Output

    impossible
    
  • Input

    WWW
    WBB
    WBB
    

    Output

    possible
    
  • Input

    ...
    ...
    ...
    

    Output

    possible
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++