Rain Forest Canopy#6376

Rain Forest Canopy

10 seconds
64 megabytes
Very easy

A tropical rainforest is typically divided into four main layers: the emergent, canopy, understory, and forest floor layers. Of the four, it is quite tricky to distinguish the emergent layer from the canopy layer. The emergent layer contains a small number of very large trees, which grow above the general canopy, reaching heights of to metres. The canopy layer is the richest layer of the diverse rainforest, and ranges in heights of to metres tall. Because of biodiversity crisis, monitoring rainforest canopy is the mission of Whole Forest Observatory, which is trying to identify suitable canopy research sites.

A group of engineers have found a simple satellite imagery technique that can mark canopy layers on a spot image of a wide rainforest area. The spot image is a square and is stored as pixels, i.e., small cells containing either a 1 or a 0. Each pixel carries some information about a particular km^2 region. A pixel location contains a 1 if part or its entire represented region is a canopy layer and a 0 if otherwise.

The following assumptions hold:

Write a program that reads spot images and correctly counts the number of canopy layers in these images.

Input

The input consists of up to test cases. Each test case describes a spot image of a rainforest area, which starts on a new line with a positive integer , (1 \leq N \leq 40) indicating the dimension of the image. The next lines of each test case delineate the pixelated representation of the image.

Output

For each test case, produce a single line of output that starts with the prefix "Case #x: " where represents the case number (starting from one and incrementing at each new test case), followed by a single space, and then the result, i.e., the number of canopy layers in the spot image.

Examples

Example 1

Loading
Loading