1. 


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #352 - (The Seasonal War)
* http://online-judge.uva.es/p/v3/352.html
*
* @author Fabian Seidl
* @author Marcel Sachse
* @version 1.0, 07.07.2009
*
* Status : Accepted
* Runtime: 0.096
*/

import java.io.BufferedInputStream;
import java.util.Scanner;


public class Main {

public static void main(String[] args)
{
BufferedInputStream bin = new BufferedInputStream(System.in);
Scanner scanner = new Scanner(bin);
int lines;
int iCounter=0;
while(scanner.hasNextInt())
{
iCounter++;
String image ="";
lines=Integer.parseInt(scanner.nextLine());
for(int i=0;i<lines;i++)
{
image += scanner.nextLine().trim()+" ";
}
String[] ia =image.split(" ");
int eCounter=0;
for(int i=0;i<lines;i++)
{
if(ia[i].indexOf("1")>=0)
{
deleteEagle(ia[i].indexOf("1"),i,lines,ia);
i--;
eCounter++;
}
}

System.out.println("Image number "+iCounter+" contains " +eCounter+ " war eagles.");
}
}

static void deleteEagle(int x, int y,int l, String [] img)
{
String tmps = img[y].substring(0, x)+"0"+img[y].substring(x+1, img[y].length());
img[y]=tmps;

for(int i=-1 ; i<=1;i++ )
{
if(y+i>=0)
if(y+i<=l-1)
for(int j=-1 ; j<=1;j++ )
{
if(x+j>=0)
if(x+j<=img[x].length()-1)
if(img[y+i].charAt(x+j)=='1')
deleteEagle(x+j,y+i,l,img);
}
}
}
}