ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1419. Maps of the Island Worlds

Time limit: 1.0 second
Memory limit: 64 MB
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:
  1. 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.
  2. 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

inputoutput
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