Population Explosion 

You just received a call from NASA's chief scientist who is working on a habitable structure to be built on the moon. He has designed various models of enclosed cities that people could live in, but he is unsure as to how these models will stand up to population growth. Therefore, since your name has become synonymous with "He Can Program Anything From Neat, Flashy Space Games That Entangle You For Hours To Highly Sophisticated Super Spy Surveillance Satellite Image Enhancement Algorithms," he immediately called you with his problem. Here is what he said:

"I need a program which will read in a set of data points that represent the location of living quarters within the city. I then want the program to simulate the creation, growth, and death of each living quarter per year based on the following rules:

  1. Every living quarter with two or three neighboring quarters survives the current year.
  2. Each living quarter with four or more neighbors dies due to over-population. Each living quarter with one or less neighbors dies from isolation.
  3. Each empty location that is adjacent to exactly three neighbors - no more, no fewer - will have someone build new living quarters in that location for the next year.

Note that each living quarter can have from zero to eight adjacent neighbors (i.e. north, south, east, west, north-west, north-east, south-west, and south-east) at any given time.

Input and Output

Each city model will have a maximum of 20 possible living quarters in the north-south direction and 20 in the east-west direction. The top left corner will be designated location 1,1 (N-S position, E-W position) and the bottom right is therefore 20,20. I want the program to read the data file and then output the existing population map for each year. Year 1 will correspond to the initial configuration. Therefore, the first map in the file should be the inital configuration. Mark empty locations with a space and living quarters with a capital letter O.

Please separate each year's output with a single line of 20 asterisks, and put a similar line both as the first and the last of the output file. Any questions?"

"Yes, one," you replied, "What will the input file look like?

"Let the first line of the file specify the number of years to run the simulation. Then, following that will be the coordinates for the initial locations. Oh, by the way, I need this to be completed within the next four hours. Talk to you later. Bye."

Sample Input

3
5 4
5 5
5 6
5 7

Sample Output

********************
 
 
 
 
   OOOO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
********************
 
 
 
    OO
    OO
    OO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
********************
 
 
 
    OO
   O  O
    OO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
********************