It was senseless, amusing, and a bit terrifying. In a sea, or maybe in an ocean, or even on a~planet completely covered with water there were 40 small islands. There was a castle with its own insignia and name on each island. Each island, or, more exactly, each castle was connected with three neighboring islands. Our neighbors were the Twelfth, the Twenty Fourth, and the Thirtieth islands…
This is how Sergey Lukyanenko, a famous Russian science fiction writer, describes in his novel a mysterious world where teenagers
have got into. A fictitious world. Or perhaps a possible one? You are to answer this question.
Well, let's formalize the literary description of the world. Assume that the islands are located at nodes of an integer grid and form a rectangle of width
W and height
H.
The following conditions are satisfied:
-
Every island is connected by bridges with exactly three neighboring islands (two islands are neighboring if the distance between them doesn't exceed 1.42). The bridges do not intersect.
-
For any two islands, there is a chain of bridges connecting them. Moreover, the destruction of any one bridge doesn't violate this property.
To make a travel in their world more convenient, aborigines use maps. A map is a rectangle of width 2W − 1 and height 2H − 1.
Islands on the map are denoted by the Latin letter 'O', and bridges are denoted by an appropriate symbol from the set '-|/\'
. Spaces denote an area without islands and bridges.
By accident, you've got a piece of paper that seems to be a map of some world. Try to determine if the image on the paper is a proper map of an Island World, i.e., if it satisfies the conditions given above.
Input
The first line contains two integers: the width M and the height N of a map. Both integers are odd and lie in the range from 1 to 99. The next N lines contain an image. Each line of the image is of length M. The cells with odd numbers of rows and columns contain the Latin letters 'O'. Other cells contain characters '-'
, '|'
, '/'
, '\'
or spaces.
Output
If the input image is a proper map of an Island World, then output the phrase “Island world”. Otherwise, output “Just a picture”.
Samples
input | output |
---|
15 9
O-O-O-O-O-O O-O
|\| | \|/|/|/|
O-O O-O O O O O
\ / /| / |/|
O-O O-O-O-O O-O
|\ | / \ |
O-O O O-O-O O-O
|/ /| |\ |\ \|
O-O-O-O-O-O-O-O
| Island world
|
5 3
O-O-O
| |
O-O-O
| Just a picture
|
Problem Author: Aleksandr Klepinin
Problem Source: The Ural State University Championship, October 29, 2005