1.

/**
 * ACM
 * UVa Status:  accepted
 * Run Time:    0.020
 * Category:    ad hoc
 * @author Evgeni Pavlidis evgenipavlidis@yahoo.de
 */
#include <iostream>

using namespace std;

#define EMPTY '.'
#define PAWN ('P' + opponent*32)
#define ROOK ('R' + opponent*32)
#define BISHOP ('B' + opponent*32)
#define KNIGHT ('N' + opponent*32)
#define QUEEN ('Q' + opponent*32)
#define KING 'K'

#define WHITE 0
#define BLACK 1
#define X_POS 0
#define Y_POS 1

#define VAL(x,y)  ((x) >= 0 && (x) < 8 && (y) >= 0 && (y) < 8)

static char board[8][8];
static int king[2][2];
static int opponent;


bool recursiveCheck(int x, int y, int dx, int dy)
{
    x += dx;
    y += dy;

    if(!VAL(x,y))
        return false;

    if(board[y][x] == QUEEN)
        return true;

    if((dx == 0 || dy == 0) && board[y][x] == ROOK)
            return true;

    if((dx != 0 && dy != 0) && board[y][x] == BISHOP)
            return true;

    if(board[y][x] != EMPTY)
        return false;

    return recursiveCheck(x, y, dx,dy);
}


bool checkKing(int color)
{
    opponent = !color;
    int x,y;
    int kingX = king[color][X_POS];
    int kingY = king[color][Y_POS];

    // check pawn
    y = kingY + 1 - (opponent*2);
    for(x=kingX-1; x <= kingX+1; x+=2)
        if(VAL(x,y) && board[y][x] == (PAWN))
            return true;
   
    // check queen/bishop/rook
    for(int dy=-1; dy <= 1; dy++)
        for(int dx=-1; dx <= 1; dx++)
            if(recursiveCheck(kingX, kingY, dx, dy))
                return true;

    // check knight
    for(x=-2; x <= 2; x++)
        for(y=-2; y <= 2; y++)
            if((x*x + y*y) == 5 && VAL(kingX+x,kingY+y))
                if(board[kingY+y][kingX+x] == KNIGHT)
                    return true;

    return false;
}

int main()
{
    string out;
    int caseNumber = 1;

    while(true)
    {
        king[WHITE][X_POS] = -1;
        king[WHITE][Y_POS] = -1;
        king[BLACK][X_POS] = -1;
        king[BLACK][Y_POS] = -1;

        for(int y=0; y < 8; y++)
        {
            for(int x=0; x < 8; x++)
            {
                cin >> board[y][x];
                if(board[y][x] == (KING+32))
                {
                    king[BLACK][X_POS] = x;
                    king[BLACK][Y_POS] = y;
                }
                else if(board[y][x] == KING)
                {
                    king[WHITE][X_POS] = x;
                    king[WHITE][Y_POS] = y;
                }
            }
            cin.ignore(1,'\n');
        }
       
        if(king[WHITE][X_POS] == -1)
            return 0;


        if(checkKing(WHITE))
            out = "white";
        else if(checkKing(BLACK))
                out = "black";
            else
                out = "no";

        cout << "Game #" << caseNumber++ << ": " << out << " king is in check." << endl;

        cin.ignore(1,'\n');
    }
   
}