Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The number of black pawns placed is not necessarily equal to the number of white pawns placed.   Lets enumerate rows and columns with integers from 1 to 8. Rows are numbered from top to bottom, while columns are numbered from left to right. Now we denote as (r, c) the cell located at the row r and at the column c.There are always two players A and B playing the game. Player A plays with white pawns, while player B plays with black ones. The goal of player A is to put any of his pawns to the row 1, while player B tries to put any of his pawns to the row 8. As soon as any of the players completes his goal the game finishes immediately and the succeeded player is declared a winner.Player A moves first and then they alternate turns. On his move player A must choose exactly one white pawn and move it one step upward and player B (at his turn) must choose exactly one black pawn and move it one step down. Any move is possible only if the targeted cell is empty. It's guaranteed that for any scenario of the game there will always be at least one move available for any of the players.Moving upward means that the pawn located in (r, c) will go to the cell (r - 1, c), while moving down means the pawn located in (r, c) will go to the cell (r + 1, c). Again, the corresponding cell must be empty, i.e. not occupied by any other pawn of any color.Given the initial disposition of the board, determine who wins the game if both players play optimally. Note that there will always be a winner due to the restriction that for any game scenario both players will have some moves available.

The input consists of the board description given in eight lines, each line contains eight characters. Character 'B' is used to denote a black pawn, and character 'W' represents a white pawn. Empty cell is marked with '.'.  It's guaranteed that there will not be white pawns on the first row neither black pawns on the last row.

Print 'A' if player A wins the game on the given board, and 'B' if player B will claim the victory. Again, it's guaranteed that there will always be a winner on the given board.

NoteIn the first sample player A is able to complete his goal in 3 steps by always moving a pawn initially located at (4, 5). Player B needs at least 5 steps for any of his pawns to reach the row 8. Hence, player A will be the winner.

#include <stdio.h>
#include <string.h>

struct Pawns {
int row[64];
int coloumn[64];
int count;
};

int main(void) {
    // your code goes here
    int i,j,min,max;
    char pos[8][8];
    struct Pawns White;
    struct Pawns Black;
    White.count=0;
    Black.count=0;
    for(i=0;i<9;i++)
        for(j=0;j<9;j++)
            scanf("%c",&pos[i][j]);

    for(i=0;i<8;i++)
        for(j=0;j<8;j++)
            if(pos[i][j]=='W')
            {
                White.row[White.count]=i;
                White.coloumn[White.count]=j;
                White.count++;
            }else if(pos[i][j]=='B')
            {
                Black.row[Black.count]=i;
                Black.coloumn[Black.count]=j;
                Black.count++;
            }
    min=999;
    for(i=0;i<White.count;i++){
        if(min>White.row[i]){
            for(j=0;j<Black.count;j++){
                if(Black.coloumn[j]==White.coloumn[i]&&White.row[i]>Black.row[j]){
                    break;
                }
            }

            if(j>=Black.count){
                min=White.row[i];
            }

        }
    }
    max=-1;
    for(i=0;i<Black.count;i++){
        if(max<Black.row[i]){
            for(j=0;j<White.count;j++){
                if(White.coloumn[j]==Black.coloumn[i]&&White.row[j]>Black.row[i]){

                    break;
                }
            }

            if(j>=White.count){
                max=Black.row[i];
            }

        }
    }

    if(min<=(7-max)){

        printf("A");
    }
    else
    printf("B");

    return 0;
}

#include <stdio.h>

int main()
{
    int i, j, k, count1 = 0, count2 = 0;
    char str[8][8];
    for(i = 0; i < 8; i++) {
        scanf("%s", str[i]);
    }
    for(i = 0; i < 8; i++) {
        for(j = 0; j < 8; j++) {
            if(str[i][j] == 'W') {
                for(k = 0; k < 8; k++) {
                    if(str[k][j] != 'B' && str[k][j] != 'W') {
                        count1++;
                        continue;
                    }
                    else {
                        break;
                    }
                }
                if(count1 != i) {
                    count1 = 0;
                    continue;
                }
                else {
                    break;
                }
            }
        }
        if(count1 > 0) {
            break;
        }
        else {
            continue;
        }
    }
    for(i = 7; i >=0; i--) {
        for(j = 0; j < 8; j++) {
            if(str[i][j] == 'B') {
                for(k = 7; k >= 0; k--) {
                    if(str[k][j] != 'B' && str[k][j] != 'W') {
                        count2++;
                        continue;
                    }
                    else {
                        break;
                    }
                }
                if(count2 != 7-i) {
                    count2 = 0;
                    continue;
                }
                else {
                    break;
                }
            }
        }
        if(count2 > 0) {
            break;
        }
        else {
            continue;
        }
    }
    if(count2 < count1){
        printf("B");
    }
    else {
        printf("A");
    }
    return 0;
}

#include <stdio.h>
//white ke atas
//black ke bawah
int main() {
	char s[8][9];
	int b=0, w=0;
	for (int i=0;i<8;i++) {
		scanf("%s", s[i]);
	}
	int minb=10, minw=10;
	for (int i=0;i<8;i++) {
		for (int j=0;j<8;j++) {
			if (s[i][j]=='W') {
				int flag=0;
				for (int k=i-1;k>=0;k--) {
					if (s[k][j]!='.') {
						flag=1;
						break;
					}
				}
				if (flag==0) {
					if (i<minw) {
						minw=i;
					}
				}
			}
		}
	}
	for (int i=0;i<8;i++) {
		for (int j=0;j<8;j++) {
			if (s[i][j]=='B') {
				int flag=0;
				for (int k=i+1;k<8;k++) {
					if (s[k][j]!='.') {
						flag=1;
						break;
					}
				}
				if (flag==0) {
					if (8-i-1<minb) {
						minb=8-i-1;
					}
				}
			}
		}
	}
	if (minw<=minb) printf("A\n");
	else printf("B\n");
}

#include<stdio.h>
#include<stdlib.h>

int main(){

  char Chess[8][8];
  int i,j,k ;
  int dist_A=0;
  int dist_B=0;
  int B_exist=0;
  int A_exist=0;

  for(i=0;i<8;i++)scanf("%s",Chess[i]);

  i=1;
  while(i<8 && dist_A==0){
     for(j=0;j<8&&dist_A==0;j++){

       if(Chess[i][j]=='W'){
        for(k=0;k<i&&B_exist==0;k++){if(Chess[k][j]=='B')B_exist=1;}
        if(B_exist==0){dist_A=i;break;}
      }
       B_exist=0;
     }

     B_exist=0;
     i=i+1;
   }
// printf("%d\n",dist_A);

  i=6;
  while(i>0 && dist_B==0){
     for(j=0;j<8;j++){
     if(Chess[i][j]=='B'){
        for(k=7;k>i;k--){if(Chess[k][j]=='W'){A_exist=1;break;}}
     if(A_exist==0){dist_B=7-i;break;}
     }
     A_exist=0;
   }
     A_exist=0;
     i=i-1;
 }

 //printf("%d\n",dist_B);
  if(dist_B==0)printf("A");
  else{
       if(dist_A==0)printf("B");
       else{
             if(dist_B>=dist_A)printf("A");
             else
              printf("B");
           }
      }

return 0 ;
}

#include <stdio.h>

int main() {
	int i, j, k, wmin, bmin, wgood, bgood;
	static char grid[8][9];

	for (i = 0; i < 8; i++)
		scanf("%s", grid[i]);
	wmin = bmin = 8;
	for (i = 0; i < 8; i++)
		for (j = 0; j < 8; j++)
			if (grid[i][j] == 'W') {
				wgood = 1;
				for (k = i - 1; k >= 0; k--)
					if (grid[k][j] != '.') {
						wgood = 0;
						break;
					}
				if (wgood && wmin > i)
					wmin = i;
			} else if (grid[i][j] == 'B') {
				bgood = 1;
				for (k = i + 1; k < 8; k++)
					if (grid[k][j] != '.') {
						bgood = 0;
						break;
					}
				if (bgood && bmin > 7 - i)
					bmin = 7 - i;
			}
	printf(wmin <= bmin ? "A\n" : "B\n");
	return 0;
}

#include <stdio.h>

int good(char cc[8][9], int i, int j) {
	int h;

	if (cc[i][j] == 'W') {
		for (h = 0; h < i; h++)
			if (cc[h][j] != '.')
				return 0;
		return 1;
	} else {
		for (h = i + 1; h < 8; h++)
			if (cc[h][j] != '.')
				return 0;
		return 1;
	}
}

int main() {
	static char cc[8][9];
	int i, j, i1, i2;

	for (i = 0; i < 8; i++)
		scanf("%s", cc[i]);
	i1 = -1;
	for (i = 0; i < 8; i++)
		for (j = 0; j < 8; j++)
			if (cc[i][j] == 'W' && good(cc, i, j)) {
				i1 = i;
				goto done1;
			}
done1:
	i2 = -1;
	for (i = 7; i >= 0; i--)
		for (j = 0; j < 8; j++)
			if (cc[i][j] == 'B' && good(cc, i, j)) {
				i2 = i;
				goto done2;
			}
done2:
	printf(i1 <= 7 - i2 ? "A\n" : "B\n");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(){

    char map[8][10]={{0}};
    int A=8,B=0;

    int i,j,k;
    for(i=0;i<8;i++)
        fgets(map[i],10,stdin);

    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(map[i][j]=='W'&&A==8){
                int no=0;
                for(k=0;k<i;k++){
                    if(map[k][j]=='B'){
                        no++;
                        break;
                    }
                }
                if(no==1) continue;
                else A=i;
            }
            if(map[i][j]=='B'){
                int no=0;
                for(k=7;k>i;k--){
                    if(map[k][j]=='W'){
                        no++;
                        break;
                    }
                }
                if(no==1) continue;
                else B=i;
            }
        }
    }
    if(A<=(7-B)) printf("A\n");
    else printf("B\n");

    return 0;

}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//#321 B. Kefa and Company
/*
typedef struct {
    long long money;
    long long friend_factor;
} friends;

int comp(const void *x, const void *y) {
    friends * a = (friends *) x;
    friends * b = (friends *) y;
    return a->money - b->money;
}
*/

int cmp(const void *a, const void *b) {
    return *(long *)a - *(long *)b;
}

int primes[1020], total = 0;

int is_prime(int num) {
    if(num <= 2) return 0;
    if(num == 2) return 1;
    if(num % 2 == 0) return 0;
    int root = sqrt(num);
    int i;
    for(i = 3; i <= root; i+= 2) {
        if(num % i == 0) return 0;
    }
    return 1;
}

void generate_primes() {
    int i;
    primes[total++] = 2;
    for(i = 3; i <= 8000; i+=2) {
        if(is_prime(i) == 1) {
            primes[total++] = i;
        }
    }
    //printf("total primes::%d\n", total);
}

int main() {

    char board[10][10];
    int i, j, min_a, min_b, k, steps;
    for(i = 0; i < 8; i++) {
        scanf("%s", board[i]);
    }

    min_a = min_b = 10;
    for(i = 0; i < 8; i++) {
        for(j = 0; j < 8; j++) {
            if(board[i][j] == 'B') {
                steps = 0;
                k = i+1;
                while(k < 8) {
                    if(board[k][j] == 'B' || board[k][j] == 'W') {
                        break;
                    }
                    k++;
                    steps++;
                }
                if(k == 8) {
                    if(steps < min_b) {
                        min_b = steps;
                    }
                }

            } else if(board[i][j] == 'W') {
                steps = 0;
                k = i-1;
                while(k >= 0) {
                    if(board[k][j] == 'B' || board[k][j] == 'W') {
                        break;
                    }
                    k--;
                    steps++;
                }
                if(k < 0) {
                    if(steps < min_a) {
                        min_a = steps;
                    }
                }
            }
        }
    }

    //printf("mina%d minb:%d\n", min_a, min_b);
    if(min_a > min_b) printf("B");
    else printf("A");
    return 0;
}

#include<stdio.h>

int main()
{
    int i,j,k;
    char ara[9][9];
    for(i=1;i<=8;i++)
   {
       for(j=1;j<=8;j++)
       {
           scanf("%c",&ara[i][j]);
       }
       getchar();
   }

    int maxb=1,minw=8,countw,countb;
    for(i=1;i<=8;i++)
    {
        for(j=1;j<=8;j++)
        {
            if(ara[j][i]=='B')
            {
                countb=1;
                for(k=j+1;k<=8;k++)
                {
                    if(ara[k][i]=='W'||ara[k][i]=='B')
                    {
                        countb=0;
                        break;
                    }

                }
                if(countb==1&&j>maxb)
                    maxb=j;
            }
            else if(ara[j][i]=='W')
            {
                countw=1;
                for(k=j-1;k>=1;k--)
                {
                    if(ara[k][i]=='W'||ara[k][i]=='B')
                    {
                        countw=0;
                        break;
                    }

                }
                if(countw==1&&j<minw)
                {
                    minw=j;

                }
            }
        }
    }

    minw=minw-1;
    maxb=8-maxb;

    if(minw<=maxb)
        printf("A\n");
    else
        printf("B\n");

    return 0;
}

#include<stdio.h>

int table[10][10];

int main(){
	int i, j, k;
	char input[10];
	int A=10, B=10;
	int temp;

	for(i=1; i<=8; i++){
		scanf("%s", input);
		for(j=0; j<8; j++){
			if(input[j] == 'W') table[i][j+1] = 1;
			else if(input[j] == 'B') table[i][j+1] = 2;
		}
	}

	for(i=1; i<=8; i++){
		for(j=1; j<=8; j++){
			if(table[j][i] == 2) break;
			if(table[j][i] == 1){
				if(j-1<A) A = j-1;
				break;
			}
		}
		for(j=8; j>=1; j--){
			if(table[j][i] == 1) break;
			if(table[j][i] == 2){
				if(8-j<B) B = 8-j;
			}
		}
	}

	if(A<=B) printf("A");
	if(A>B) printf("B");

}

#include<stdio.h>
#include<math.h>
int main()
{   char tabla[50][50];
    int beli[50][50];
    int crni[50][50];
    int a,b,c,d;
    int i;
    for(i=0;i<8;i++){
        gets(tabla[i]);
    }
   char *q=tabla[0];
   int beli_int=0;
   int beli_int1=0;
   int petlja_beli1=0;
   int petlja_beli;
   int brojac_belih=0;
   for(petlja_beli=0;petlja_beli<8;petlja_beli++){
        q=tabla[petlja_beli];
        for(beli_int=0;beli_int<8;beli_int++,q++){
   if(*q=='W'){
    beli[petlja_beli1++][beli_int1]=(petlja_beli+1)*10 + beli_int+1;
    brojac_belih++;
   }}
beli_int1=0;
   }

   int petlja_crni;
   int crni_int;
   int petlja_crni1=0;
   int crni_int1=0;
   int brojac_crnih=0;
   for(petlja_crni=0;petlja_crni<8;petlja_crni++){
        q=tabla[petlja_crni];
        for(crni_int=0;crni_int<8;crni_int++,q++){
   if(*q=='B'){
    crni[petlja_crni1++][crni_int1]=(petlja_crni+1)*10 + crni_int+1;
    brojac_crnih++;
   }
   }
crni_int1=0;
   }
int test=0;
for(test=0;test<brojac_crnih;test++){
  // printf("CRNI-%d\n",crni[test][0]);
}
for(test=0;test<brojac_belih;test++){
    //printf("BELI-%d\n",beli[test][0]);
}
int dobri_crni[50][50];
int dobri_beli[50][50];
int test_GD;
int test_GD1;
int broj_valid;
int nije_valid=0;
int crni_increaser=0;
for(test_GD1=0;test_GD1<brojac_crnih;test_GD1++){
        nije_valid=0;
        broj_valid=crni[test_GD1][0];
for(test_GD=0;test_GD<brojac_belih;test_GD++){
    if(broj_valid%10 == beli[test_GD][0]%10 && broj_valid/10<beli[test_GD][0]/10)
    {
        nije_valid=1;
        break;
    }
}
if(nije_valid == 1)
    continue;
else{
    dobri_crni[crni_increaser++][0]=broj_valid;
    nije_valid=0;
}
}
for(test=0;test<crni_increaser;test++){
   // printf("DOBRI CRNI-%d\n",dobri_crni[test][0]);
}
int beli_increaser=0;
for(test_GD1=0;test_GD1<brojac_belih;test_GD1++){
        nije_valid=0;
        broj_valid=beli[test_GD1][0];
for(test_GD=0;test_GD<brojac_crnih;test_GD++){
    if(broj_valid%10 == crni[test_GD][0]%10 && broj_valid/10>crni[test_GD][0]/10)
    {
        nije_valid=1;
        break;
    }
}
if(nije_valid == 1)
    continue;
else{
    dobri_beli[beli_increaser++][0]=broj_valid;
    nije_valid=0;
}}
for(test=0;test<beli_increaser;test++){
  // printf("DOBRI BELI-%d\n",dobri_beli[test][0]);
}
int sort;
int sort1;
int najveci_crni=dobri_crni[0][0];
for(sort=0;sort<crni_increaser-1;sort++){
    for(sort1=0;sort1<crni_increaser;sort1++){
        if(najveci_crni<dobri_crni[sort1][0]){
           najveci_crni=dobri_crni[sort1][0];
        }
    }
}
//printf("\n\n**NAJVECI CRNI%d",najveci_crni);
int najveci_beli=dobri_beli[0][0];
for(sort=0;sort<beli_increaser-1;sort++){
    for(sort1=0;sort1<beli_increaser;sort1++){

        if(najveci_beli>dobri_beli[sort1][0]){
           najveci_beli=dobri_beli[sort1][0];
        }
    }
}
//printf("\n\n**NAJVECI BELI%d",najveci_beli);
int zadnji_korak_b;
int zadnji_korak_c;
zadnji_korak_b=najveci_beli/10;
zadnji_korak_c=najveci_crni/10;
//printf("\n\nBELI - %d\nCRNI - %d",abs(1-zadnji_korak_b),abs(8-zadnji_korak_c));
if(abs(1-zadnji_korak_b)<=abs(8-zadnji_korak_c)){
printf("A");
}
else
    printf("B");
}

#include<stdio.h>
#include<math.h>

char data[10][10];

int main()
{
    while(scanf("%s",&data[0])!=EOF)
    {
        int i;
        int j;
        for(i=1;i<8;i++)
            scanf("%s",&data[i]);
        int k;
        int mina=9999,minb=9999;
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
            {
                if(data[i][j]=='W')
                {
                    for(k=0;k<i;k++)
                    {
                        if(data[k][j]=='B')
                            break;
                    }
                    if(k==i)
                    {
                        if(i<mina)
                            mina=i;
                    }
                }
                if(data[i][j]=='B')
                {
                    for(k=i+1;k<8;k++)
                    {
                        if(data[k][j]=='W')
                            break;
                    }
                    if(k==8)
                    {
                        if( (7-i)<minb)
                            minb=(7-i);
                    }
                }
            }
        }
            if(mina<=minb)
                printf("A\n");
            else
                printf("B\n");
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

main()
    {
        int i,j,na,nb,stepA,stepB;
        int Ax[64],Ay[64],Bx[64],By[64];
        char s[9];
        na = 0;
        nb = 0;
        for (i=0;i<8;i++)
            {
                scanf("%s",s);
                for (j=0;j<8;j++)
                    {
                        if (s[j]=='W')
                            {
                                Ax[na] = i;
                                Ay[na] = j;
                                na++;
                            }
                        else
                            {
                                if (s[j]=='B')
                                    {
                                        Bx[nb] = i;
                                        By[nb] = j;
                                        nb++;
                                    }
                            }
                    }
            }

        stepA = 10;
        for (i=0;i<na;i++)
            {
                //Chercher Ay[i] dans By
                j = 0;
                while ((j<nb) && ((By[j]!=Ay[i]) || ((By[j]==Ay[i]) && (Ax[i]<Bx[j])))) j++;
                if (j==nb) if (Ax[i]<stepA) stepA = Ax[i];

            }

        stepB = 10;
        for (i=0;i<nb;i++)
            {
                j = 0;
                while ((j<na) && ((Ay[j]!=By[i]) || ((Ay[j]==By[i]) && (Ax[j]<Bx[i])))) j++;
                if (j==na) if ((7-Bx[i])<stepB) stepB = 7 - Bx[i];
            }
        if (stepA<=stepB) printf("A");
        else printf("B");
    }

#include <stdio.h>

int main() {
	int i, j, k, wmin, bmin, wgood, bgood;
	static char grid[8][9];

	for (i = 0; i < 8; i++)
		scanf("%s", grid[i]);
	wmin = bmin = 8;
	for (i = 0; i < 8; i++)
		for (j = 0; j < 8; j++)
			if (grid[i][j] == 'W') {
				wgood = 1;
				for (k = i - 1; k >= 0; k--)
					if (grid[k][j] != '.') {
						wgood = 0;
						break;
					}
				if (wgood && wmin > i)
					wmin = i;
			} else if (grid[i][j] == 'B') {
				bgood = 1;
				for (k = i + 1; k < 8; k++)
					if (grid[k][j] != '.') {
						bgood = 0;
						break;
					}
				if (bgood && bmin > 7 - i)
					bmin = 7 - i;
			}
	printf("%c\n", wmin <= bmin ? 'A' : 'B');
	return 0;
}

//http://codeforces.com/contest/592/problem/A

#include<stdio.h>
#include<stdlib.h>

int main(void){
    int i,j,trash;
    int bmin=10,wmin=10;
    int bm=0,wm=0;
    char a[8][8]={0};
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            scanf("%c",&a[i][j]);
        }
        scanf("%c",&trash);
    }

    for(j=0;j<8;j++){
        bm=0;
        wm=0;
        for(i=0;i<8;i++){
            if(a[i][j]=='.'){
                wm++;
            }
            else if(a[i][j]=='B'){
                wm=10;
                break;
            }
            else break;
        }
        for(i=7;i>=0;i--){
            if(a[i][j]=='.'){
                bm++;
            }
            else if(a[i][j]=='W'){
                bm=10;
                break;
            }
            else break;
        }
        if(bm<bmin){
            bmin=bm;
        }
        if(wm<wmin){
            wmin=wm;
        }
    }

    if(wmin<=bmin){
        printf("A\n");
    }
    else{
        printf("B\n");
    }
    return 0;

}

#include<stdio.h>
#include<string.h>
int main(){
    int Blacklength=100,WhiteLength=100;
    char s[8][8];
    int i,j,k,flag;
    for(i=0;i<8;i++){
        gets(s[i]);
    }
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(s[i][j]=='B'){
                k=i;
                flag=0;
                while(k<=7){
                    if(s[k][j]=='W'){
                        flag=1;
                        break;
                    }
                    k++;
                }
                if(flag==0){
                    if((7-i)<Blacklength)Blacklength=7-i;
                }
            }
        }
    }

    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(s[i][j]=='W'){
                k=i;
                flag=0;
                while(k>=0){
                    if(s[k][j]=='B'){
                        flag=1;
                        break;
                    }
                    k--;
                }
                if(flag==0){
                    if(i<WhiteLength)WhiteLength=i;
                }
            }
        }
    }
    if(Blacklength>=WhiteLength)printf("A\n");
    else printf("B\n");
    return 0;
}

#include<stdio.h>
int minm(int a,int b)
{
    return (a<b?a:b);
}
int main()
{
    int i,j;
    char a[8][8];
    for(i=0;i<8;i++)
            scanf("%s",a[i]);
    int mw=8,mb=8;
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(a[j][i]=='W')
                mw=minm(mw,j);
            else if(a[j][i]=='B')
                break;
        }
        for(j=7;j>=0;j--)
            if(a[j][i]=='B')
                mb=minm(mb,7-j);
            else if(a[j][i]=='W')
                break;
    }
    //printf("mw=%d mb=%d\n",mw,mb);
    if(mw<=mb)
        printf("A\n");
    else
        printf("B\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char s[9][9];
    int i,j,w[9],b[9],wneed=0,bneed=0,check[9][9],no1=0,no2=0,k;
    for(i=0;i<8;i++){
        scanf("%s",s[i]);
    }
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            check[i][j]=0;
        }
    }
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(s[i][j]=='W') check[i][j]=1;
            else if(s[i][j]=='B') check[i][j]=2;
        }
    }
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
                no1=0;
            //printf("check[%d][%d] %d\n",i,j,check[i][j]);
            if(check[i][j]==1){
                for(k=i-1;k>=0;k--){
                    //printf("checkkkk[%d][%d] %d\n",k,j,check[k][j]);
                    if(check[k][j]==2){
                        no1=1;break;
                    }
                }
                //printf("no1 %d\n",no1);
                if(no1==0) {
                    wneed=i;
                    //printf(" wneed %d\n",wneed);
                    break;
                }
            }
        }
        if(wneed !=0) break;
    }
    //printf("\n");
    for(i=7;i>=0;i--){
        for(j=0;j<8;j++){
            no2=0;
            //printf("check[%d][%d] %d\n",i,j,check[i][j]);
            if(check[i][j]==2){
                for(k=i+1;k<8;k++){
                    //printf("checkkkkk[%d][%d] %d\n",k,j,check[k][j]);
                    if(check[k][j]==1){
                        no2=1;break;
                    }
                }
                //printf("no2 %d\n",no2);
                if(no2==0) {bneed=7-i;//printf("bneed %d\n",bneed);
                break;}
            }
        }
        if(bneed !=0) break;
    }
   // printf("w %d b %d\n",wneed,bneed);
    if(bneed<wneed) printf("B\n");
    else printf("A\n");
    return 0;
}

#include <stdio.h>

int main(void) {

    char d[8][8];
    short i, j, k , minA = 9, minB = 9;

    for (i = 0; i < 8; i++)
        scanf("%s", d[i]);

    for (i = 0; i < 8; i++)
        for (j = 0; j < 8; j++) {
            short f = 0;
            if (d[i][j] == 'W') {
                f = 1;
                for (k = i - 1; k >= 0; k--) {
                    if (d[k][j] == '.')
                        continue;
                    else {
                        f = 0;
                        break;
                    }
                }
                if (f && i < minA) minA = i;
            }
            if (d[i][j] == 'B') {
                f = 1;
                for (k = i + 1; k < 8; k++) {
                    if (d[k][j] == '.')
                        continue;
                    else {
                        f = 0;
                        break;
                    }
                }
                if (f && 7 - i < minB) minB = 7 - i;
            }
        }

    if (minA <= minB) puts("A");
    else puts("B");

    return 0;
}

#include<stdio.h>
int main(){
	//A white pawn up
	//B black pawn down
	char papan[10][10];
	for(int i=0;i<8;i++){
		gets(papan[i]);
	}
	int finalB = -1;
	for(int col = 0;col<8;col++){
		for(int row = 0;row<8;row++){
			int resB = -1;
			if(papan[row][col]=='B'){
				resB=0;
				for(int b=row+1;b<8;b++){
					if(papan[b][col]=='W') {
						resB = -1;
						break;
					}
					resB++;
				}
				if(finalB==-1&&resB>=0){
					finalB = resB;
				}
				if(finalB>resB&&resB!=-1){
					finalB = resB;
				}
			}
		}
		//printf("Final B: %d\n",finalB);
	}
	int finalA = -1;
	for(int colA = 0;colA<8;colA++){
		for(int rowA = 7;rowA>=0;rowA--){
			int resA = -1;
			if(papan[rowA][colA]=='W'){
				resA=0;
				for(int a=rowA-1;a>=0;a--){
					if(papan[a][colA]=='B') {
						resA = -1;
						break;
					}
					resA++;
				}
				if(finalA==-1&&resA>=0){
					finalA = resA;
				}
				if(finalA>resA&&resA!=-1){
					finalA = resA;
				}
			}
		}
		//printf("Final A: %d\n",finalA);
	}
	if(finalB<finalA){
		printf("B\n");
	}
	else if(finalB==finalA){
		printf("A\n");
	}
	else{
		printf("A\n");
	}
}

#include <stdio.h>

int main()
{
	char board[8][8];

	int i, j, k;
	char aux;
	for (i=0; i<8; i++){
		for (j=0; j<=8; j++){
			scanf("%c", &aux);
			if (aux!=10) board[i][j]=aux;
		}
	}

	int minA=40, minB=40, clean;
	for (i=0; i<8; i++){
		for (j=0; j<8; j++){
			clean = 1;
			if (board[i][j]=='W'){
				for (k=0; k<i && clean==1; k++) if (board[k][j]=='B') clean=0;
				if (clean==1 && i<minA) minA=i;
			}
			if (board[i][j]=='B'){
				for (k=i+1; k<8 && clean==1; k++) if (board[k][j]=='W') clean=0;
				if (clean==1 && 8-i<minB) minB=8-i;
			}
		}
	}

	if (minA<minB) printf("A\n");
	else printf("B\n");

	return 0;
}

#include<stdio.h>
int main() {
    char board[8][8];
    int i,j;
    for(i=0; i<8; i++) {
        for(j=0; j<8; j++) {
            board[i][j]=getchar();
        }
        getchar();//read newline
    }
    /*
    for(i=0; i<8; i++) {
        for(j=0; j<8; j++) {
            printf("%c",board[i][j]);
        }
        printf("\n");
    }
    */

    int white_step=8;
    int find=0;
    int row=0;
    int move[8];
    for(i=0; i<8; i++) {
        move[i]=1;
    }
    while(!find && row<8) {
        //printf("row = %d\n",row);
        int col;
        for(col=0; col<8; col++) {
            if(board[row][col]=='B') move[col]=0;
            else if(board[row][col]=='W' && move[col]==1) {
                find=1;
                white_step=row;
                break;
            }
        }
	/*
        for(col=0; col<8; col++) {
            printf(" %d",move[col]);
	}
	printf("\n");
	*/

        row++;
    }
    int black_step=8;
    find=0;
    row=7;
    for(i=0; i<8; i++) {
        move[i]=1;
    }
    while(!find && row>=0) {
        int col;
        for(col=0; col<8; col++) {
            if(board[row][col]=='W') move[col]=0;
            else if(board[row][col]=='B' && move[col]==1) {
                find=1;
                black_step=8-row;
                break;
            }
        }
        row--;
    }
    /*
    printf("white step = %d\n",white_step);
    printf("black step = %d\n",black_step);
    */
    if(white_step<black_step) {
        printf("A\n");
    } else {
        printf("B\n");
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	int r,c,k,flag,tempw,tempb,mova=10,movb=10;
	char s[10][10];
	for(r=1;r<=8;r++)
	{
		scanf("%s",s[r]);
		getchar();
	}
	for(r=1;r<=8;r++)
	{
		for(c=0;c<8;c++)
		{
			tempw=10;
			tempb=10;
			flag=0;
			if(s[r][c]=='W')
			{
				for(k=r-1;k>=1;k--)
				{
					if(s[k][c]=='B'||s[k][c]=='W')
					{
						flag=1;
						break;
					}
				}
				if(flag==0)
				{
					tempw=r-1;
				}
				if(tempw<mova)
				{
					mova=tempw;
				}
	//			printf("W>> %d    %d,%d--%d\n",flag,r,c,tempw);
			}
			if(s[r][c]=='B')
			{
				for(k=r+1;k<=8;k++)
				{
					if(s[k][c]=='B'||s[k][c]=='W')
					{
						flag=1;
						break;
					}
				}
				if(flag==0)
				{
					tempb=8-r;
				}
			//	printf("B>> %d    %d,%d--%d\n",flag,r,c,tempb);
				if(tempb<movb)
				{
					movb=tempb;
				}
			}

		}
	}
//	printf("%d %d\n",mova,movb);

	if(mova<=movb)
	printf("A");
	else
	printf("B");
	return 0;

}

#include<stdio.h>
int main(){
int i,j,wmoves,bmoves,wrow,wcol,brow,bcol;
char arr[8][8];
int warr[8];
int barr[8];
int temp[8];
int bmin,wmin;
for(i=0; i<8; i++)
    scanf("%s",arr[i]);
    for(i=0; i<8; i++)
        {
            warr[i]=0;
            barr[i]=0;
            temp[i]=0;
        }
for(i=0; i<8; i++){
for(j=0; j<8; j++){

    if(arr[i][j]=='W'){
            if(warr[j]==0 &&temp[j]==0){
            warr[j]=i;
            temp[j]=1;}
            if(barr[j]>0)
                barr[j]=0;

        }
     if(arr[i][j]=='B')
            {
                if(barr[j]==0)
                    barr[j]++;
                else
                    barr[j]=1;
                  if(warr[j]==0)
                        temp[j]=-1;
            }
      if(arr[i][j]=='.'){
        if(barr[j]>0)
            barr[j]++;
      }
     // printf("w%d b%d",warr[j],barr[j]);
}
//printf("\n");
}
bmin=0;
wmin=0;
//for(i=0; i<8; i++)
  //  printf("%d %d\n",warr[i],barr[i]);
for(i=0; i<8; i++){
    if(wmin==0&&warr[i]>0)
      wmin=warr[i];
    else if(warr[i]>0&&warr[i]<wmin)
        wmin=warr[i];
 if(bmin==0&&barr[i]>0)
      bmin=barr[i];
  else if(barr[i]>0&&barr[i]<bmin)
        bmin=barr[i];
}
//printf("%d %d\n",wmin,bmin);
if(wmin<=bmin-1)
    printf("A\n");
else
    printf("B\n");
return 0;
}

#include <stdio.h>
#include <string.h>

char board[10][10];

int main() {
	int r, c, noway, step, black, white;

	for (r = 0; r < 8; r++)
		gets(board[r]);

	black = white = 999;

	for (c = 0; c < 8; c++) {

		noway = 0;
		step = 999;
		for (r = 0; r < 8; r++) {
			if (board[r][c] == 'B')
				noway = 1;
			if (board[r][c] == 'W' && !noway) {
				step = r;
				noway = 1;
			}
		}
		if (step < white)
			white = step;

		noway = 0;
		step = 999;
		for (r = 7; r >= 0; r--) {
			if (board[r][c] == 'W')
				noway = 1;
			if (board[r][c] == 'B' && !noway) {
				step = 7 - r;
				noway = 1;
			}
		}
		if (step < black)
			black = step;

	}

	if (white <= black)
		puts("A");
	else
		puts("B");

	return 0;
}

#include <stdio.h>

#define INF 9

int main()
{
	char brd[8][9];
	int i, j, mina = INF, minb = INF;

	for (i = 0; i < 8; i++)
		gets (brd[i]);

	for (i = 0; i < 8; i++) {
		for (j = 7; j >= 0 && brd[j][i] == '.'; j--)
			;
		if (j >= 0 && brd[j][i] == 'B')
			if (7 - j < minb)
				minb = 7 - j;
	}

	for (i = 0; i < 8; i++) {
		for (j = 0; j < 8 && brd[j][i] == '.'; j++)
			;
		if (j < 8 && brd[j][i] == 'W')
			if (j < mina)
				mina = j;
	}

	putchar (mina <= minb ? 'A' : 'B');

	return 0;
}

#include<stdio.h>
int main(){
int i,j,a[8][8],distA=10,distB=10;
for(i=0;i<8;i++)
	for(j=0;j<8;j++)
		a[i][j]=-1;
//
for(i=0;i<8;i++){
char temp;
for(j=0;j<8;j++){
scanf(" %c",&temp);
if(temp=='W'){
a[i][j]=0;
}
if(temp=='B'){
a[i][j]=1;
}
}
//printf("done\n");
}
//check whites
for(j=0;j<8;j++){
for(i=0;i<8;i++){
if(a[i][j]==0) distA = (i<distA)?i:distA;
else if(a[i][j]==1) break;}
//printf("A=%d\n",distA);
}
for(j=7;j>=0;j--){
for(i=7;i>=0;i--){
if(a[i][j]==1) distB = (7-i<distB)?7-i:distB;
else if(a[i][j]==0) break;}
//printf("B=%d\n",distB);
}
if(distA<=distB)
printf("A");
else
printf("B");
return 0;
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int findWayUp(int a[8][8], int, int);
int findWayDown(int a[8][8], int, int);

int findWayUp(int a[8][8], int currI, int currJ)
{
    int result = 0;
    if (currI == 0) result = 1;
    else
    {
        if (a[currI-1][currJ] == 0) result = 1 * findWayUp(a, currI-1, currJ);
        else result = 0;
    }
    return result;
}

int findWayDown(int a[8][8], int currI, int currJ)
{
    int result = 0;
    if (currI == 7) result = 1;
    else
    {
        if (a[currI+1][currJ] == 0) result = 1 * findWayDown(a, currI+1, currJ);
        else result = 0;
    }
    return result;
}

int main()
{
    int board[8][8];
    char ch;

    for (int i = 0; i < 8; i++)
    {
        for (int j = 0; j < 8; j++)
        {
            scanf("%c", &ch);
            switch (ch)
            {
                case '.':
                    board[i][j] = 0;
                    break;

                case 'W':
                    board[i][j] = 1;
                    break;

                case 'B':
                    board[i][j] = 2;
                    break;
            }
        }
       scanf("%*c");
    }

    int movesA = 0, movesB = 0;
    for (int i = 0; i < 8; i++)
        for (int j = 0; j < 8; j++)
        {
            if (board[i][j] == 1)
                if (findWayUp(board, i, j))
                    if ((movesA == 0) || (i < movesA)) movesA = i;
            if (board[i][j] == 2)
                if (findWayDown(board, i, j))
                    if ((movesB == 0) || ((7-i) < movesB)) movesB = 7-i;
        }
    char winner;
    if (movesA <= movesB) winner = 'A';
    else winner = 'B';
    printf("%c", winner);

    return 0;
}

#include <stdio.h>

int checkFront(char *matrix, int pos){
	for(pos = pos + 8; pos < 64; pos += 8){
		if(matrix[pos] != '.'){
			return 0;
		}
	}

	return 1;
}

int checkBack(char* matrix, int pos){
	for(pos = pos - 8; pos >= 0; pos -= 8){
		if(matrix[pos] != '.'){
			return 0;
		}
	}

	return 1;
}

int main(){
	int i, a, b;
	char matrix[64];

	for(i = 0; i < 64; i++){
		scanf("%c", &matrix[i]);

		if(matrix[i] == '\n'){
			i--;
		}
	}

	for(i = 0, a = -1, b = -1; i < 64; i++){
		if(matrix[i] == 'B'){
			if(checkFront(matrix, i) == 1){
				a = i;
			}
		}

		if(b == -1 && matrix[i] == 'W'){
			if(checkBack(matrix, i) == 1){
				b = i;
			}
		}
	}

	// printf("%d %d\n", a, b);
	// printf("%d %d\n", (6 - a/8), (b/8));

	printf("%c\n", (a/8)<=(7 - b/8)?'A':'B');

}
// 1452670234372

#include<stdio.h>
#include <string.h>

int main()
{
	int data[8][8];
    int min_white=8,min_black=8;
    int i,j;
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
			 data[i][j]=getchar();
		}
        getchar();
    }
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(data[j][i]=='B')
			{
				break;
			}
            if(data[j][i]=='W' && min_white>j)
            {
				min_white=j;
				break;
			}
        }
    }

    for(i=0;i<8;i++)
    {
        for(j=7;j>=0;j--)
        {
            if(data[j][i]=='W')
			{
				break;
			}
            if(data[j][i]=='B' && min_black>(7-j))
            {
				min_black=7-j;
				break;
			}
        }
    }
    printf(min_black<min_white?"B\n":"A\n");
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{  int i,j;
char ** str=(char **)malloc(sizeof(char*)*8);
for(i=0;i<8;i++)
str[i]=(char *)malloc(sizeof(char)*8);
for(i=0;i<8;i++)
scanf("%s",str[i]);
int k,min_a,min_b,diff_a,diff_b;
for(i=0;i<8;i++)
{ for(j=0;j<8;j++)
       {  if(str[i][j]=='W')
              {   for(k=i-1;k>=0;k--)
                  {  if(str[k][j]== '.')
                      continue;
                      else
                        break;
                  }
                  if(k<0)
            break;
            else
                continue;
       }
       }
       if(j<=7)
       {min_a=i;
       break;}
}

for(i=7;i>=0;i--)
{ for(j=0;j<8;j++)
       {  if(str[i][j]=='B')
           {   for(k=i+1;k<=7;k++)
                  {  if(str[k][j]== '.')
                      continue;
                  else
                    break;
                  }
                  if(k>7)
            break;
            else
                continue;
       }
       }
       //printf("yes");
       if(j<=7)
       {//printf("yes");
           min_b=i;
       break;}
}
//printf("%d %d",min_a, min_b);
diff_a=min_a;
diff_b=7-min_b;
if(diff_a==diff_b)
    printf("A");
    else if(diff_b>diff_a)
        printf("A");
      else if(diff_b<diff_a)
         printf("B");
}

#include <stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int i,k,j,flag=0;
    char a[8][10];
    for(i=0;i<8;i++)
    {
        scanf("%s",a[i]);
    }
    int minw=8,minb=8;
    for(i=0;i<8;i++)
    {
        for(j=0;j<strlen(a[i]);j++)
        {
            if(a[i][j]=='W')
            {
                flag=0;
                for(k=0;k<i;k++)
                {
                    if(a[k][j]=='B')
                    {
                        flag++;
                        break;
                    }
                }
                if(flag==0)
                {
                    if(minw>i)
                    minw=i;
                }
            }
            else if(a[i][j]=='B')
            {
                flag=0;
                for(k=7;k>i;k--)
                {
                    if(a[k][j]=='W')
                    {
                        flag++;
                        break;
                    }
                }
                if(flag==0)
                {
                    if(minb>7-i)
                    minb=7-i;
                }
            }
        }
    }
    if(minw>minb)
    printf("B");
    else
    printf("A");
    return 0;
}

/* Problem: 592A - PawnChess */
/* Solver: Gusztav Szmolik */

#include <stdio.h>
#include <string.h>

int main ()
    {
    unsigned short fw;
    unsigned short fb;
    unsigned short i;
    unsigned char s[10];
    unsigned short j;
    unsigned char b[8][8];
    unsigned short wsn;
    unsigned short bsn;
    unsigned short sc;
    unsigned short k;

    fw = fb = 0;
    for (i = 0; i < 8; i++)
        {
        if (scanf("%9s",s) != 1)
            return -1;
        if (strlen(s) != 8)
            return -1;
        for (j = 0; j < 8; j++)
            {
            if (s[j] != '.' && s[j] != 'W' && s[j] != 'B')
                return -1;
            if (s[j] == 'W')
                {
                if (!i)
                    return -1;
                if (!fw)
                    fw = 1;
                }
            else if (s[j] == 'B')
                {
                if (i == 7)
                    return -1;
                if (!fb)
                    fb = 1;
                }
            b[i][j] = s[j];
            }
        }
    if (!fw || !fb)
        return -1;
    wsn = bsn = 8;
    for (i = 0; i < 8; i++)
        for (j = 0; j < 8; j++)
            {
            if (b[i][j] != '.')
                {
                sc = 0;
                k = i;
                }
            if (b[i][j] == 'W')
                {
                while (k)
                    {
                    k--;
                    if (b[k][j] == '.')
                        sc++;
                    else
                        {
                        sc = 0;
                        break;
                        }
                    }
                if (sc && sc < wsn)
                    wsn = sc;
                }
            else if (b[i][j] == 'B')
                {
                while (k < 7)
                    {
                    k++;
                    if (b[k][j] == '.')
                        sc++;
                    else
                        {
                        sc = 0;
                        break;
                        }
                    }
                if (sc && sc < bsn)
                    bsn = sc;
                }
            }
    if (wsn == 8 && bsn == 8)
        return -1;
    printf (wsn <= bsn ? "A\n" : "B\n");
    return 0;
    }

#include<stdio.h>
int main()
{
    int i,j,minA=8, rA, rB,minB=8,k,flag;
    char A[10][10];
    for(i=0;i<8;++i)
    {
        for(j=0;j<8;++j)
            scanf("%c",&A[i][j]);
        getchar();
    }
    for(i=0;i<8;++i)
    {
        for(j=0;j<8;++j)
        {
            if(A[i][j] == 'W')
            {
                flag = 0;
                for(k=i-1;k>=0;--k)
                {
                    if(A[k][j] != '.')
                    {
                        flag = 1;
                        break;
                    }
                }
                if(flag == 0)
                {
                    rA = i;
                    if(rA < minA)
                        minA = rA;
                }
            }
            else if(A[i][j] == 'B')
            {
                flag = 0;
                for(k=i+1;k<8;++k)
                {
                    if(A[k][j] != '.')
                    {
                        flag = 1;
                        break;
                    }
                }
                if(flag == 0)
                {
                    rB = 7-i;
                    if(rB < minB)
                        minB = rB;
                }
            }
        }
    }
    if(minA <= minB)
        printf("A\n");
    else
        printf("B\n");
    return 0;
}

#include<stdio.h>

int main()
{
    char str[9][9], my[8];
    int i, j, minB, minA, positB, positA, no1, no2, ans1, ans2,posita, positb;

    for(i=1; i<=8; i++)
    {
        gets(my);
        for(j=1; j<=8; j++)
        {
            str[i][j] = my[j-1];
        }
    }

    minB=7;
    minA=7;
    for(i=1; i<=8; i++)
    {
        no1 = 0;
        no2 = 0;
        positB=1;
        positb = 8;
        positA=8;
        posita = 1;
        for(j=1; j<=8; j++)
        {
            if(str[j][i] == 'B')
            {
                no1++;
                if(j<positb)
                {
                    positb = j;
                }

                positB=j;
            }

            if(str[j][i] == 'W')
            {
                no2++;
                if(j<positA)
                {
                    positA = j;
                }
                posita=j;
            }
        }

        if(no1>0 && no2==0)
        {
            ans1 = 8 - positB;
            if(minB>ans1)
                minB = ans1;
        }
        else if(no1==0 && no2>0)
        {
            ans2 = positA - 1;
            if(minA>ans2)
                minA = ans2;
        }

        else if(no1>0 && no2>0)
        {
            if(posita<positB)
            {
                ans1 = 8-positB;
                if(minB>ans1)
                {
                    minB = ans1;
                }
            }
             if(positb>positA)
             {
                 ans2 = positA -1;
                 if(minA>ans2)
                 {
                    minA = ans2;
                 }

             }
        }
    }
    if(minA <= minB)
        printf("A");
    else
        printf("B");

    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    char board[8][9];
    int countr, countc;
    int W = 8, B = 8,Wb = 8, Bb = 8, checkB = 0;
    for(countr = 0; countr < 8; countr++)
    {
        for(countc = 0; countc < 9; countc++)
        {
            scanf("%c", &board[countr][countc]);
        }
    }
    for(countc = 0; countc < 8; countc++)
    {
        checkB = 0;
        for(countr = 0; countr < 8; countr++)
        {
            if(board[countr][countc] == 'W')
            {
                if(checkB != 1)
                {
                    if(W>countr)
                        W = countr;
                }
                B = 8;
            }
            if(board[countr][countc] == 'B')
            {
                if(B>7-countr)
                    B = 7-countr;
                checkB=1;
            }
        }
        if(B<Bb)
        {
            Bb = B;
        }
        if(W<Wb)
        {
            Wb = W;
        }
    }
    if(Bb<Wb)
        printf("B");
    else
        printf("A");
    return 0;
}

#include <stdio.h>
int main(void)
{
    int i, j, k, f,t, f2, count, count_2, min =8, min_2 =8;
    char chess[8][10];

    for(i=0; i<8; i++) scanf("%s", chess[i]);

    for(j=0; j<8; j++){
        for(k=0; k<8; k++){
            if(chess[j][k] == 'W'){
                f = 1;
                for(t=j; t>=0; t--){
                    if(chess[t][k] == 'B'){
                        f = 0;
                        break;
                    }
                }
                if(f){
                        count = j;
                        if(count<min) min = count;
                }
            }
            else if(chess[j][k] == 'B'){
                f2 = 1;
                for(t=j; t<8; t++){
                    if(chess[t][k] == 'W'){
                        f2 = 0;
                        break;
                    }
                }
                if(f2){
                    count_2 = 7 - j;
                    if(count_2 < min_2) min_2 = count_2;
                }
            }

        }
    }
    if(min<=min_2) printf("A");
    else printf("B");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char board[8][8], x[10];
    int i, j, k, black = 10, white = 10;
    for (i = 0; i < 8; i++){
        scanf("%s", &x);
        for (j = 0; j < 8; j++) board[i][j] = x[j];
    }
    for (i = 0; i < 8; i++){
        for (j = 0; j < 8; j++){
            if (board[i][j] == 'B'){
                for (k = i+1; k < 8; k++) if (board[k][j] != '.') break;
                if ((k == 8) && ((7 - i) < black)) black = (7-i);
            }else if (board[i][j] == 'W'){
                for (k = i-1; k >= 0; k--) if (board[k][j] != '.') break;
                if ((k == -1) && (i < white)) white = i;
            }
        }
    }
    printf((white <= black)?"A\n":"B\n");
    return 0;
}

//592A-codeforces//

#include<stdio.h>
    char a[8][9];

int checkcolW(int i,int j)
{
    int n;
    for(n=i-1;n>=0;n--)
    {
        if(a[n][j]!='.')
        return 0;
    }
    return 1;
}

int checkcolB(int i,int j)
{
    int n;
    for(n=i+1;n<8;n++)
    {
        if(a[n][j]!='.')
        return 0;
    }
    return 1;
}

main()
{

    int i,j,maxb=0,mina=7,black,white;
    for(i=0;i<8;i++)
    {
        for(j=0;j<9;j++)
        scanf("%c", &a[i][j]);
    }
    /*printf("\n");

    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        printf("%c", a[i][j]);
        printf("\n");
    }*/

    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(a[i][j]=='.')
            continue;
            if(a[i][j]=='B')
            {
                if(checkcolB(i,j)==1)
                {
                    if(i>=maxb)
                maxb=i;
                }
            }
            else
            {
                if(checkcolW(i,j)==1)
                {
                    if(i<=mina)
                    mina=i;
                }
            }
        }
    }

    black=7-maxb;
    white=mina;
    if(white>black)
    printf("B");
    else
    printf("A");
}

#include<stdio.h>
int min1=100000000,min2=10000000,answ,ansb;
char a[8][8];
void white()
{
	int i,j;
	for(j=0;j<8;j++)
	{
		for(i=0;i<8;i++)
		{
			if(a[i][j]=='B')
			{
				break;
			}
			else if(a[i][j]=='W')
			{
				answ=i;
				if(answ < min1)
				{
					min1=answ;
				}

			}
		}
	}

}
void black()
{
	int i,j;
	for(j=0;j<8;j++)
	{
		for(i=7;i>=0;i--)
		{
			if(a[i][j]=='W')
			{
				break;
			}
			else if(a[i][j]=='B')
			{
				ansb=7-i;
				if(ansb < min2)
				{
					min2=ansb;
				}
			}
		}
	}

}
int main()
{
	int i,j,w,myrow,mycol,b;
	char c;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf("%c",&a[i][j]);
		}
		scanf("%c",&c);
	}
	white();
	black();
//	printf("%d %d\n",min1,min2);
	if(min1>min2)
	{
		printf("B\n");
	}
	else
	{
		printf("A\n");
	}
	return 0;
}

#include <stdio.h>
int main()
{
  char board[8][8];
  int i,j;
  for(i=0;i<8;i++){
    scanf("%8s",board[i]);
  }
  int min_a = 8;
  int min_b = 8;
  for(i=0;i<8;i++){
    int b_lo = 8;
    int b_hi = -1;
    int w_lo = 8;
    int w_hi = -1;
    for(j=0;j<8;j++){
      if(board[j][i]=='B'){
        if(j<b_lo){
          b_lo=j;
        }
        if(b_hi<j){
          b_hi=j;
        }
      }
      if(board[j][i]=='W'){
        if(j<w_lo){
          w_lo=j;
        }
        if(w_hi<j){
          w_hi=j;
        }
      }
    }
    int dist_a = w_lo;
    int dist_b = 7 - b_hi;
    if((w_hi<b_hi)&&(dist_b<min_b)){
      min_b=dist_b;
    }
    if((w_lo<b_lo)&&(dist_a<min_a)){
      min_a=dist_a;
    }
  }
  if(min_a<=min_b){
    printf("A\n");
  }else{
    printf("B\n");
  }
  return 0;
}

#include <stdio.h>
int main()
{   int data[8][8];
    int min_white=8,min_black=8;
    int i,j;
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
            data[i][j]=getchar();
        getchar();
    }
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(data[j][i]=='B'){break;}
            if(data[j][i]=='W' && min_white>j)
                {min_white=j;break;}
        }
    }

    for(i=0;i<8;i++)
    {
        for(j=7;j>=0;j--)
        {
            if(data[j][i]=='W'){break;}
            if(data[j][i]=='B' && min_black>(7-j))
                {min_black=7-j;break;}
        }
    }
    printf(min_black<min_white?"B":"A");
    return 0;
}

#include <stdio.h>
#include <string.h>

int main(void) {
    int h;
    int i;
    int j;
    int k;
    int ultB = 0;
    int ultBant;
    int ultW = 0;
    int ultWant;
    char tabuleiro[8][8];
    for(h = 0; h < 8; h++)
    {
        scanf("%s", &tabuleiro[h]);
    }
    for(i = 0; i < 8; i++)
    {
        for(j = 0; j < 8; j++)
        {
            if(tabuleiro[i][j] == 'B')
            {
                ultBant = ultB;
                ultB = i;
                for(k = i+1; k < 8; k++)
                {
                    if(tabuleiro[k][j] == 'W')
                    {
                        ultB = ultBant;
                    }
                }
            }
        }

    }
    for(i = 7; i >-1; i--){
        for(j = 0; j < 8; j++)
        {
            if(tabuleiro[i][j] == 'W')
            {
                ultWant = ultW;
                ultW = i;
                for(k = i-1; k > -1; k--)
                {
                    if(tabuleiro[k][j] == 'B')
                    {
                        ultW = ultWant;
                    }
                }
            }
        }
    }
    if((7 - ultB) >= ultW){
        printf("A");
    }
    else{
        printf("B");
    }
    return 0;
}

#include<stdio.h>

int main()
{
	char b[8][8];
	int w_min=10, b_min=10, i, j;
	for(i=0; i<8; i++)
		scanf("%s", b[i]);
	for(j=0; j<8; j++)
	{
		for(i=0; i<8; i++)
		{
			if(b[i][j]=='B')
				break;
			else if(b[i][j]=='W')
			{
				if(i<w_min)
					w_min=i;
				break;
			}

		}
		for(i=8; i>=0; i--)
		{
			if(b[i][j]=='W')
				break;
			else if(b[i][j]=='B')
			{
				if((8-i-1)<b_min)
					b_min=8-i-1;
				break;
			}
		}
	}
	if(w_min<=b_min)
		printf("A\n");
	else
		printf("B\n");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

int min(int a , int b) {
    return a > b ? b : a;
}
bool ok = false;
int main() {
char cell[8][8];
int r,c;
char aux;
for(int i = 0;i<8;i++) {
   for(int j=0;j<8;j++)
       scanf(" %c",&cell[i][j]);
   getchar();
}
int mina = 100 , minb = 100;
for (int i=0;i<8;++i) {
    for(int j=0;j<8;++j) {
       ok = true;
       if(cell[i][j]=='W') {
          for(int k=i;k>0;--k) {
            if( cell[k-1][j] == 'B' && cell[i][j] == 'W') {
               ok = false;
            }
          }
          if (ok)
          {
            mina = min(mina,i);
          }

        }
       else if(cell[i][j] == 'B') {
          ok = true;
         for(int z = i;z<8;++z) {
            if(cell[z+1][j] == 'W') {
              ok = false;
            }
          }
          if (ok)
          {
            minb = min(minb,8- i );
          }
       }

    }
}
//for (int i=0;i<=7;++i)
//    for(int j=0;j<=7;++j)
//       printf("%c",cell[i][j]);
//    printf("\n");

if(mina>=minb)
   printf("B\n");
else if(mina < minb )
   printf("A\n");

  //printf("%d\n",mina);
   //printf("%d\n",minb);
return 0;
}

#include<stdio.h>
int main()
{
    char str[10][10];
    int i, j, flag, k, W, W_min=7, B, B_min=7;

    for(i=0; i<8; i++)
    {
        gets(str[i]);
    }
    for(i=0; i<8; i++)
    {
        for(j=0; j<8; j++)
        {
            if(str[i][j]=='B')
            {
                for(k=i+1, flag=0; k<8; k++)
                {
                    if(str[k][j]=='W')
                    {
                        flag = 1;
                        break;
                    }
                }
                if(flag==0)
                {
                    B = 7-i;
                    if(B<B_min)
                        B_min = B;
                }

            }
            else if(str[i][j]=='W')
            {
                for(k=i-1, flag=0; k>=0; k--)
                {
                    if(str[k][j]=='B')
                    {
                        flag = 1;
                        break;
                    }
                }
                if(flag==0)
                {
                    W = i;
                    if(W<W_min)
                        W_min = W;
                }
            }
        }
    }

    if(W_min>B_min)
        printf("B\n");
    else if(B_min>=W_min)
        printf("A\n");

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int Free_Way(const char *matrix,int col,int str,int derect)
{
    int i,flag=0;
    if(derect==1)
        for(i=str-1;i>=0;i--) {
	    if (matrix[i*8+col]!='.') {
	        flag=1;
		break;
	    }
	}
    else
        for(i=str+1;i<8;i++)
	    if (matrix[i*8+col]!='.') {
	        flag=1;
		break;
	    }
    return !flag;
}

int main()
{
    char sq[8][8];
    int i,j,rw=0,rb=0;
    char c;
    for(i=0;i<8;i++) {
        for(j=0;j<8;j++) {
            c=getchar();
            sq[i][j]=c;
        }
        c=getchar();
    }
    for(i=1;(i<8)&&(rw==0);i++)
        for(j=0;j<8;j++)
            if ((sq[i][j]=='W')&&(Free_Way(&sq[0][0],j,i,1))) {
                rw=i;
                break;
            }
    for(i=6;(i>=0)&&(rb==0);i--)
        for(j=0;j<8;j++)
            if ((sq[i][j]=='B')&&(Free_Way(&sq[0][0],j,i,-1))) {
                rb=7-i;
                break;
            }
    if (rw<=rb)
        printf("A");
    else
        printf("B");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main() {
    char board[9][9], none;
    int r, c, k;
    int jam=0, minW=9, minB=9;

    for(r=1; r<9; r++){
        for(c=1; c<9; c++){
            board[r][c] = getchar();
        }
        none = getchar();
    }

    for(r=1; r<9; r++){
        for(c=1; c<9; c++){
            if(board[r][c] == 'W'){
                jam = 0;
                for(k=r-1; k>0; k--){
                    if(board[k][c] != '.'){
                        jam = 1;
                        break;
                    }
                }
                if(jam == 0){
                    if(minW > r-1){
                        minW = r-1;
                    }
                }
            }
            else if(board[r][c] == 'B'){
                jam = 0;
                for(k=r+1; k<9; k++){
                    if(board[k][c] != '.'){
                        jam = 1;
                        break;
                    }
                }
                if(jam == 0){
                    if(minB > 8-r){
                        minB = 8-r;
                    }
                }
            }
        }
    }
    if(minW <= minB){
        printf("A\n");
    }
    else{
        printf("B\n");
    }
    //printf("%d %d\n", minW, minB);
    return 0;
}

#include "stdio.h"
#include "string.h"

int min(int a,int b){
    return a<b?a:b;
}

int main(int argc, char* argv[])
{
    char s[8][8];
    int i,j,k,ans=8,ansa=8;
    int fg;
    for(i=0;i<8;i++)
    {
        scanf("%s",&s[i]);
    }

    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(s[i][j]=='B')
            {
                fg=1;
                for(k=i+1;k<8;k++){
                    if(s[k][j]!='.'){
                        fg=0;
                        break;
                    }
                }
                if(fg){
                    ans=min(ans,8-i-1);
                }
            }
            if(s[i][j]=='W')
            {
                fg=1;
                for(k=i-1;k>=0;k--)
                {
                    if(s[k][j]!='.')
                    {
                        fg=0;
                        break;
                    }
                }
                if(fg){
                    ansa=min(ansa,i);

                }
            }
        }
    }
    if(ansa>ans)
        printf("B\n");
    else
        printf("A\n");

    return 0;
}

#include <stdio.h>
#define BSIZE 8

int main()
{
    char board[BSIZE][BSIZE + 2];
    int i, j;
    for (i = 0; i < BSIZE; ++i) gets(board[i]);
    int a = 0x7fffffff, b = 0x7fffffff;
    for (i = 0; i < BSIZE; ++i) {
        // Scan downwards
        for (j = 0; j < BSIZE && board[j][i] == '.'; ++j);
        if (j < BSIZE && board[j][i] == 'W' && j < a) a = j;
        // Scan upwards
        for (j = BSIZE - 1; j >= 0 && board[j][i] == '.'; --j);
        if (j >= 0 && board[j][i] == 'B' && BSIZE - 1 - j < b) b = BSIZE - 1 - j;
    }
    putchar(a <= b ? 'A' : 'B');
    return 0;
}

#include<stdio.h>
char map[10][10];
int MIN(int a,int b){
    return a<b?a:b;
}
int main()
{
    int i,j;
    for(i=0;i<8;i++){
        scanf("%s",map[i]);
    }
    int mina=8,minb=8;
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(map[j][i]!='.')
            {
                if(map[j][i]=='W')
                {
                    mina=MIN(mina,j);
                    break;
                }
                else break;
            }
        }
    }
    for(i=0;i<8;i++)
    {
        for(j=7;j>=0;j--)
        {
            if(map[j][i]!='.')
                {
                    if(map[j][i]=='B')
                    {
                        minb=MIN(minb,7-j);
                        break;
                    }
                    else break;
                }
        }
    }
    if(mina<=minb)printf("A\n");
    else printf("B\n");
    return 0;
}

#include <stdio.h>

int main(void)
{
    char board[8][8];

    int i, j;
    for (i = 0; i < 8; i++)
        for (j = 0; j < 8; j++)
            scanf(" %c", &board[i][j]);

    int mina = 10, minb = 10;
    for (i = 0; i < 8; i++)
    {
        for (j = 0; j < 8; j++)
        {
            if (board[j][i] == 'B')
                break;
            else if (board[j][i] == 'W')
            {
                if (mina > j)
                    mina = j;
                 break;
            }
        }

        int k = 7;
        for (; k >= j; k--)
        {
            if (board[k][i] == 'W')
                break;
            else if (board[k][i] == 'B')
            {
                if (minb > 7-k)
                    minb = 7-k;
                 break;
            }
        }
    }
    printf("%c", mina <= minb ? 'A' : 'B');
    return 0;
}

#include<stdio.h>
int main ()
{
    int amin,bmax,i,j,flag=1;
    char c[9][9];
    for(i=1; i<=8; i++)
        scanf("%s",c[i]);
    for(j=0; j<8; j++)
    {
        for(i=1; i<=8; i++)
        {
            if(c[i][j]=='B')
                break;
            else if(c[i][j]=='W')
            {
                if (flag==1)
                {
                    amin=i;
                    flag=0;
                }
                else if(i<amin)
                    amin=i;
                break;
            }
        }
    }
    flag=1;
    for(j=0;j<8;j++)
    {
        for(i=8;i>=1;i--)
        {
            if(c[i][j]=='W')
                    break;
            else if(c[i][j]=='B')
            {
                if (flag==1)
                {
                    bmax=i;
                    flag=0;
                }
                else if(i>bmax)
                {
                    bmax=i;
                }
                break;
            }
        }
    }
    amin--;
    bmax=8-bmax;
    if(amin<=bmax)
        printf("A\n");
    else
        printf("B\n");
    return 0;
}

/*A*/
#include<stdio.h>
#include<string.h>
int main()
{
	char chess[9][9];
	int A,B;
	int i,j;
	int p;
	int flag;
	//while(1)
	//{
		for(i=1;i<=8;i++)
		    scanf("%s",chess[i]);
		A=8;B=8;
		for(i=1;i<=8;i++)
		{
			for(j=0;j<8;j++)
			{
			    if(chess[i][j]=='W')
			    {
			    	flag=1;
			    	for(p=i-1;p>=1;p--)
			    	{
			    		if(chess[p][j]!='.')
			    		{
			    			flag=0;
			    			break;
						}
					}
					if(flag==1&&(i-1)<A)
					    A=i-1;
				}
				else if(chess[i][j]=='B')
				{
					flag=1;
					for(p=i+1;p<=8;p++)
					{
						if(chess[p][j]!='.')
						{
							flag=0;
							break;
						}
					}
					if(flag==1&&(8-i)<B)
					    B=8-i;
				}
			}
		}
		if(A<=B)
		    printf("A\n");
		else
		    printf("B\n");
//	}
	return 0;
}

#include <stdio.h>
int main()
{
    int i,j,A=7,B=0;
    char arr[8][9];
    for(i=0;i<8;i++)
        gets(arr[i]);
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
            if(arr[j][i]=='B')
                break;
            else if(arr[j][i]=='W' && j<A)
            {
                A=j;
                break;
            }
        for(j=7;j>=0;j--)
            if(arr[j][i]=='W')
                break;
            else if(arr[j][i]=='B' && j>B)
            {
                B=j;
                break;
            }
    }
    printf("%c",A<=(7-B)?'A':'B');
    return 0;
}

#include "stdio.h"

int main()
{
    int i, j, k,mina=7, minb=7;
    char x[8][8];
    for (i=0;i<8;i++)
        scanf("%s",x[i]);
    for (i=0;i<8;i++)
        for (j=0;j<8;j++)
        {
            if (x[i][j]=='W')
            {
                int clear=1;
                for (k=i-1;k>=0;k--)
                    if (x[k][j]!='.')
                        clear=0;
                if (clear!=0)
                    mina=mina<i?mina:i;
            }
            if (x[i][j]=='B')
            {
                int clear=1;
                for (k=i+1;k<8;k++)
                    if (x[k][j]!='.')
                        clear=0;
                if (clear!=0)
                    minb=minb<(7-i)?minb:(7-i);
            }
        }
    printf("%c\n",mina<=minb?'A':'B');
    return 0;
}

#include<stdio.h>

int main()
{
    char b[8][8];
    int w_min=10, b_min=10, i, j;
    for(i=0; i<8; i++)
        scanf("%s", b[i]);
    for(j=0; j<8; j++)
    {
        for(i=0; i<8; i++)
        {
            if(b[i][j]=='B')
                break;
            else if(b[i][j]=='W')
            {
                if(i<w_min)
                    w_min=i;
                break;
            }

        }
        for(i=8; i>=0; i--)
        {
            if(b[i][j]=='W')
                break;
            else if(b[i][j]=='B')
            {
                if((8-i-1)<b_min)
                    b_min=8-i-1;
                break;
            }
        }
    }
    if(w_min<=b_min)
        printf("A\n");
    else
        printf("B\n");
    return 0;
}

#include <stdio.h>
int main(void)
{
    int i, j, k, f,t, f2, count, count_2, min =8, min_2 =8;
    char chess[8][10];

    for(i=0; i<8; i++) scanf("%s", chess[i]);

    for(j=0; j<8; j++){
        for(k=0; k<8; k++){
            if(chess[j][k] == 'W'){
                f = 1;
                for(t=k; t>=0; t--){
                    if(chess[t][k] == 'B'){
                        f = 0;
                        break;
                    }
                }
                if(f){
                        count = j;
                        if(count<min) min = count;
                }
            }
            else if(chess[j][k] == 'B'){
                f2 = 1;
                for(t=k; t<8; t++){
                    if(chess[t][k] == 'W'){
                        f2 = 0;
                        break;
                    }
                }
                if(f2){
                    count_2 = 7 - j;
                    if(count_2 < min_2) min_2 = count_2;
                }
            }

        }
    }
    if(min<=min_2) printf("A");
    else printf("B");
    return 0;
}

#include<stdio.h>

int main()
{
	char b[8][8];
	int w_min=10, b_min=10, i, j;
	for(i=0; i<8; i++)
		scanf("%s", b[i]);
	for(j=0; j<8; j++)
	{
		for(i=0; i<8; i++)
		{
			if(b[i][j]=='B')
				break;
			else if(b[i][j]=='W')
			{
				if(i<w_min)
					w_min=i;
				break;
			}

		}
		for(i=8; i>=0; i--)
		{
			if(b[i][j]=='W')
				break;
			else if(b[i][j]=='B')
			{
				if((8-i-1)<b_min)
					b_min=8-i-1;
				break;
			}
		}
	}
	if(w_min<b_min)
		printf("A\n");
	else
		printf("B\n");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int Free_Way(const char *matrix,int col,int str,int derect)
{
    int i,flag=0;
    if(derect==1)
        for(i=str-1;i>=0;i--) {
            if (matrix[i*8+col]!=0) {
                flag=1;
                break;
            }
        }
    else
        for(i=str+1;i<8;i++)
            if (matrix[i*8+col]!=0) {
                flag=1;
                break;
            }
    return !flag;
}

int main()
{
    char sq[8][8];
    int i,j,rw=0,rb=0;
    char str[8];
    for(i=0;i<8;i++) {
        scanf("%s",str);
        for(j=0;j<8;j++)
            sq[i][j]=str[j];
    }
    for(i=1;(i<8)&&(rw==0);i++)
        for(j=0;j<8;j++)
            if ((sq[i][j]=='W')&&(Free_Way(&sq[0][0],j,i,1))) {
                rw=i;
                break;
            }
    for(i=6;(i>=0)&&(rb==0);i--)
        for(j=0;j<8;j++)
            if ((sq[i][j]=='B')&&(Free_Way(&sq[0][0],j,i,-1))) {
                rb=7-i;
                break;
            }
    if (rw<=rb)
        printf("A");
    else
        printf("B");
    return 0;
}

#include <stdio.h>
int main()
{
    int x=0,y=0,i,j,g,f=0,k=0,finalB,finalW;
    char s,str[100][100];
    for(i=0;i<8;i++){
        scanf("%s",str[i]);
    }
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(str[j][i]=='B'){
                x=j+1;
            }
            if(str[j][i]=='W'){
                y=j+1;
                if(f==0){
                    g=y;
                }
                f++;
            }
        }
        if(x>y){
            if(x>=finalB){
                finalB=x;
            }
            if((9-g)>=finalW){
                finalW=g;
            }
        }
        f=0;
    }
    if(finalW>=finalB){
        printf("A");
    }
    else{
        printf("B");
    }
    return 0;
}

#include<stdio.h>
#include<math.h>

char data[10][10];

int main()
{
    while(scanf("%s",&data[0])!=EOF)
    {
        int i;
        int j;
        for(i=1;i<8;i++)
            scanf("%s",&data[i]);
        int k;
        int mina=9999,minb=9999;
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
            {
                if(data[i][j]=='W')
                {
                    for(k=0;k<i;k++)
                    {
                        if(data[k][j]=='B')
                            break;
                    }
                    if(k==i)
                    {
                        if(i<mina)
                            mina=i;
                    }
                }
                if(data[i][j]=='B')
                {
                    for(k=i+1;k<8;k++)
                    {
                        if(data[k][j]=='W')
                            break;
                    }
                    if(k==8)
                    {
                        if( (7-i)<minb)
                            minb=(7-i);
                    }
                }
            }
        }
            if(mina<minb)
                printf("A\n");
            else
                printf("B\n");
    }
    return 0;
}

#include <stdio.h>
int main()
{
    int x=0,y=0,i,j,g=0,f=0,k=0,finalB=0,finalW=0;
    char str[100][100];
    for(i=0;i<8;i++){
        scanf("%s",str[i]);
    }
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(str[j][i]=='B'){
                x=j+1;
            }
            if(str[j][i]=='W'){
                y=j+1;
                if(f==0){
                    g=9-y;
                }
                f++;
            }
        }
        if(x>y||x==0||y==0){
            if(x>=finalB){
                finalB=x;
            }
            if(g>=finalW){
                finalW=g;
            }
        }
        f=0;
        x=0;
        y=0;
    }
    if(finalW>=finalB){
        printf("A");
    }
    else{
        printf("B");
    }
    printf("\n%d %d",finalB,finalW);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{   char tabla[50][50];
    int beli[50][50];
    int crni[50][50];
    int a,b,c,d;
    int i;
    for(i=0;i<8;i++){
        gets(tabla[i]);
    }
   char *q=tabla[0];
   int beli_int=0;
   int beli_int1=0;
   int petlja_beli1=0;
   int petlja_beli;
   int brojac_belih=0;
   for(petlja_beli=0;petlja_beli<8;petlja_beli++){
        q=tabla[petlja_beli];
        for(beli_int=0;beli_int<8;beli_int++,q++){
   if(*q=='W'){
    beli[petlja_beli1++][beli_int1]=(petlja_beli+1)*10 + beli_int+1;
    brojac_belih++;
   }}
beli_int1=0;
   }

   int petlja_crni;
   int crni_int;
   int petlja_crni1=0;
   int crni_int1=0;
   int brojac_crnih=0;
   for(petlja_crni=0;petlja_crni<8;petlja_crni++){
        q=tabla[petlja_crni];
        for(crni_int=0;crni_int<8;crni_int++,q++){
   if(*q=='B'){
    crni[petlja_crni1++][crni_int1]=(petlja_crni+1)*10 + crni_int+1;
    brojac_crnih++;
   }
   }
crni_int1=0;
   }
int test=0;
for(test=0;test<brojac_crnih;test++){
  // printf("CRNI-%d\n",crni[test][0]);
}
for(test=0;test<brojac_belih;test++){
    //printf("BELI-%d\n",beli[test][0]);
}
int dobri_crni[50][50];
int dobri_beli[50][50];
int test_GD;
int test_GD1;
int broj_valid;
int nije_valid=0;
int crni_increaser=0;
for(test_GD1=0;test_GD1<brojac_crnih;test_GD1++){
        nije_valid=0;
        broj_valid=crni[test_GD1][0];
for(test_GD=0;test_GD<brojac_belih;test_GD++){
    if(broj_valid%10 == beli[test_GD][0]%10 && broj_valid/10 <beli[test_GD][0]%10)
    {
        nije_valid=1;
        break;
    }
}
if(nije_valid == 1)
    continue;
else{
    dobri_crni[crni_increaser++][0]=broj_valid;
    nije_valid=0;
}
}
for(test=0;test<crni_increaser;test++){
   // printf("DOBRI CRNI-%d\n",dobri_crni[test][0]);
}
int beli_increaser=0;
for(test_GD1=0;test_GD1<brojac_belih;test_GD1++){
        nije_valid=0;
        broj_valid=beli[test_GD1][0];
for(test_GD=0;test_GD<brojac_crnih;test_GD++){
    if(broj_valid%10 == crni[test_GD][0]%10 && broj_valid/10>crni[test_GD][0]/10)
    {
        nije_valid=1;
        break;
    }
}
if(nije_valid == 1)
    continue;
else{
    dobri_beli[beli_increaser++][0]=broj_valid;
    nije_valid=0;
}}
for(test=0;test<beli_increaser;test++){
  // printf("DOBRI BELI-%d\n",dobri_beli[test][0]);
}
int sort;
int sort1;
int najveci_crni=dobri_crni[0][0];
for(sort=0;sort<crni_increaser-1;sort++){
    for(sort1=0;sort1<crni_increaser;sort1++){
        if(najveci_crni<dobri_crni[sort1][0]){
           najveci_crni=dobri_crni[sort1][0];
        }
    }
}
//printf("\n\n**NAJVECI CRNI%d",najveci_crni);
int najveci_beli=dobri_beli[0][0];
for(sort=0;sort<beli_increaser-1;sort++){
    for(sort1=0;sort1<beli_increaser;sort1++){

        if(najveci_beli>dobri_beli[sort1][0]){
           najveci_beli=dobri_beli[sort1][0];
        }
    }
}
//printf("\n\n**NAJVECI BELI%d",najveci_beli);
int zadnji_korak_b;
int zadnji_korak_c;
zadnji_korak_b=najveci_beli/10;
zadnji_korak_c=najveci_crni/10;
//printf("\n\nBELI - %d\nCRNI - %d",abs(1-zadnji_korak_b),abs(8-zadnji_korak_c));
if(abs(1-zadnji_korak_b)<=abs(8-zadnji_korak_c)){
printf("A");
}
else
    printf("B");
}

#include<stdio.h>
int main() {
  char board[8][8];
  int i,j;
  for(i=0;i<8;i++) {
    for(j=0;j<8;j++) {
      board[i][j]=getchar();
    }
    getchar();//read newline
  }
  int white_step=0;
  int find=0;
  int row=1;
  int move[8];
  for(i=0;i<i;i++) {
    move[i]=1;
  }
  while(!find && row<8) {
    int col;
    for(col=0;col<8;col++) {
      if(board[row][col]=='B') move[col]=0;
      else if(board[row][col]=='W' && move[col]==1) {
        find=1;
        white_step=row;
        break;
      }
    }
    row++;
  }
  int black_step=0;
  find=0;
  row=7;
  for(i=0;i<8;i++) {
    move[i]=1;
  }
  while(!find && row>=0) {
    int col;
    for(col=0;col<8;col++) {
      if(board[row][col]=='W') move[col]=0;
      else if(board[row][col]=='B' && move[col]==1) {
        find=1;
        black_step=8-row;
        break;
      }
    }
    row--;
  }
  if(white_step<black_step) {
    printf("A\n");
  } else {
    printf("B\n");
  }
  return 0;
}

#include "stdio.h"
#include "string.h"

int main(int argc, char* argv[])
{
	char s[10];
	int i,j,ans=8,ans2=-1;
	for(i=0;i<8;i++)
	{
		scanf("%s",s);
	}

	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			if(s[j]=='B')
			{
				ans=i+1;
				if(i>ans)
					ans=i+1;
			}
			if(s[j]=='W')
			{
				ans2=i+1;
				if(i<ans2)
					ans2=i+1;
			}
		}
	}
	if(ans2>(8-ans))
		printf("B\n");
	else
		printf("A\n");

	return 0;
}

#include <stdio.h>
int main(void)
{
    int i, j, k, f,t, f2, count, count_2, min =8, min_2 =8;
    char chess[8][10];

    for(i=0; i<8; i++) scanf("%s", chess[i]);

    for(j=0; j<8; j++){
        for(k=0; k<8; k++){
            if(chess[j][k] == 'W'){
                f = 1;
                for(t=0; t<8; t++){
                    if(chess[t][k] == 'B'){
                        f = 0;
                        break;
                    }
                }
                if(f){
                        count = j;
                        if(count<min) min = count;
                }
            }
            else if(chess[j][k] == 'B'){
                f2 = 1;
                for(t=0; t<8; t++){
                    if(chess[t][k] == 'W'){
                        f2 = 0;
                        break;
                    }
                }
                if(f2){
                    count_2 = 7 - j;
                    if(count_2 < min_2) min_2 = count_2;
                }
            }

        }
    }
    if(min<=min_2) printf("A");
    else printf("B");
    return 0;
}

#include <stdio.h>

int main()
{
	char board[8][8];

	int i, j, k;
	char aux;
	for (i=0; i<8; i++){
		for (j=0; j<=8; j++){
			scanf("%c", &aux);
			if (aux!=10) board[i][j]=aux;
		}
	}

	int minA=40, minB=40, clean;
	for (i=0; i<8; i++){
		for (j=0; j<8; j++){
			clean = 1;
			if (board[i][j]=='W'){
				for (k=0; k<i && clean==1; k++) if (board[k][j]=='B') clean=0;
				if (clean==1 && i<minA) minA=i;
			}
			if (board[i][j]=='B'){
				for (k=i+1; k<8 && clean==1; k++) if (board[k][j]=='W') clean=0;
				if (clean==1 && 8-i<minB) minB=8-i;
			}
		}
	}

	if (minA<=minB) printf("A\n");
	else printf("B\n");

	return 0;
}

#include<stdio.h>
int main ()
{
    int amin,bmax,i,j,flag=1;
    char c[9][9];
    for(i=1; i<=8; i++)
        scanf("%s",c[i]);
    for(j=1; j<=8; j++)
    {
        for(i=1; i<=8; i++)
        {
            if(c[i][j]=='B')
                break;
            else if(c[i][j]=='W')
            {
                if (flag==1)
                {
                    amin=i;
                    flag=0;
                }
                else if(i<amin)
                {
                    amin=i;
                }
                break;
            }
        }
    }
    flag=1;
    for(j=1;j<=8;j++)
    {
        for(i=8;i>=1;i--)
        {
            if(c[i][j]=='W')
                    break;
            else if(c[i][j]=='B')
            {
                if (flag==1)
                {
                    bmax=i;
                    flag=0;
                }
                else if(i>bmax)
                {
                    bmax=i;
                }
                break;
            }
        }
    }
    bmax=8-bmax;
    if(amin<=bmax)
        printf("A\n");
    else
        printf("B\n");
    return 0;
}

/*A*/
#include<stdio.h>
#include<string.h>
int main()
{
	char chess[9][9];
	int A,B;
	int i,j;
	int p;
	int flag;
	//while(1)
	//{
		for(i=1;i<=8;i++)
		    scanf("%s",chess[i]);
		A=8;B=8;
		for(i=1;i<=8;i++)
		{
			for(j=0;j<8;j++)
			{
			    if(chess[i][j]=='W')
			    {
			    	flag=1;
			    	for(p=i-1;p>=1;p--)
			    	{
			    		if(chess[p][j]!='.')
			    		{
			    			flag=0;
			    			break;
						}
					}
					if(flag==1&&i<A)
					    A=i;
				}
				if(chess[i][j]=='B')
				{
					flag=1;
					for(p=i+1;p<=8;p++)
					{
						if(chess[p][j]!='.')
						{
							flag=0;
							break;
						}
					}
					if(flag==1&&(8-i)<B)
					    B=8-i;
				}
			}
		}
		if(A<=B)
		    printf("A\n");
		else
		    printf("B\n");
//	}
	return 0;
}

#include<stdio.h>

int main()
{
    int i,j,k;
    char ara[9][9];
    for(i=1;i<=8;i++)
   {
       for(j=1;j<=8;j++)
       {
           scanf("%c",&ara[i][j]);
       }
       getchar();
   }

    int maxb=1,minw=8,countw,countb;
    for(i=1;i<=8;i++)
    {
        for(j=1;j<=8;j++)
        {
            if(ara[j][i]=='B')
            {
                countb=1;
                for(k=j+1;k<=8;k++)
                {
                    if(ara[k][i]=='W'||ara[k][i]=='B')
                    {
                        countb=0;
                        break;
                    }

                }
                if(countb==1&&j>maxb)
                    maxb=j;
            }
            else if(ara[j][i]=='W')
            {
                countw=1;
                for(k=j-1;k>=1;k--)
                {
                    if(ara[k][i]=='W'||ara[k][i]=='B')
                    {
                        countw=0;
                        break;
                    }

                }
                if(countw==1&&j<minw)
                {
                    minw=j;

                }
            }
        }
    }

    minw=minw-1;
    maxb=8-maxb;

    if(minw<maxb)
        printf("A\n");
    else
        printf("B\n");

    return 0;
}

#include <stdio.h>
#include <string.h>

int main(void) {
    int h;
    int i;
    int j;
    int k;
    int ultB = 0;
    int ultBant;
    int ultW = 0;
    int ultWant;
    char tabuleiro[8][8];
    for(h = 0; h < 8; h++)
    {
        scanf("%s", &tabuleiro[h]);
    }
    for(i = 0; i < 8; i++)
    {
        for(j = 0; j < 8; j++)
        {
            if(tabuleiro[i][j] == 'B')
            {
                ultBant = ultB;
                ultB = i;
                for(k = i+1; k < 8; k++)
                {
                    if(tabuleiro[k][j] == 'W')
                    {
                        ultB = ultBant;
                    }
                }
            }
        }

    }
    for(i = 7; i >-1; i--){
        for(j = 0; j < 8; j++)
        {
            if(tabuleiro[i][j] == 'W')
            {
                ultWant = ultW;
                ultW = i;
                for(k = i-1; k > -1; k--)
                {
                    if(tabuleiro[k][j] == 'B')
                    {
                        ultW = ultWant;
                    }
                }
            }
        }
    }
    if((7 - ultB) > ultW){
        printf("A");
    }
    else{
        printf("B");
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(){

  char Chess[8][8];
  int i,j,k ;
  int dist_A=0;
  int dist_B=0;
  int B_exist=0;
  int A_exist=0;

  for(i=0;i<8;i++)scanf("%s",Chess[i]);

  i=1;
  while(i<8 && dist_A==0){
     for(j=0;j<8&&dist_A==0;j++){

       if(Chess[i][j]=='W'){
        for(k=0;k<i&&B_exist==0;k++){if(Chess[k][j]=='B')B_exist=1;}
        if(B_exist==0){dist_A=i;break;}
      }

     }

     B_exist=0;
     i=i+1;
   }
 //printf("%d\n",dist_A);

  i=6;
  while(i>0 && dist_B==0){
     for(j=0;j<8;j++){
     if(Chess[i][j]=='B'){
        for(k=7;k>i;k--){if(Chess[k][j]=='W'){A_exist=1;break;}}
     if(A_exist==0){dist_B=7-i;break;}
     }
   }
     A_exist=0;
     i=i-1;
 }

 //printf("%d\n",dist_B);
  if(dist_B==0)printf("A");
  else{
       if(dist_A==0)printf("B");
       else{
             if(dist_B>=dist_A)printf("A");
             else
              printf("B");
           }
      }

return 0 ;
}

#include "stdio.h"
#include "string.h"

int main(int argc, char* argv[])
{
    char s[10][10];
    int i,j,k,ans=8,ansa=-1;
    int fg;
    for(i=0;i<8;i++)
    {
        scanf("%s",&s[i]);
    }

    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(s[i][j]=='B')
            {
                fg=1;
                for(k=i+1;k<8;k++){
                    if(s[k][j]!='.'){
                        fg=0;
                        break;
                    }
                }
                if(fg){
                    ans=i;
                    if(i>ans)
                        ans=i;
                }
            }
            if(s[i][j]=='W')
            {
                fg=1;
                for(k=i-1;k>=0;k--){
                    if(s[k][j]!='.'){
                        fg=0;
                        break;
                    }
                }
                if(fg){
                    ansa=i;
                    if(i<ansa)
                        ansa=i;
                }
            }
        }
    }
    if(ansa>(8-ans))
        printf("B\n");
    else
        printf("A\n");

    return 0;
}

#include<stdio.h>
int main() {
  char board[8][8];
  int i,j;
  for(i=0;i<8;i++) {
    for(j=0;j<8;j++) {
      board[i][j]=getchar();
    }
    getchar();//read newline
  }
  int white_step=0;
  int find=0;
  int row=1;
  int move[8];
  for(i=0;i<i;i++) {
    move[i]=1;
  }
  while(!find && row<8) {
    int col;
    for(col=0;col<8;col++) {
      if(board[row][col]=='B') move[col]=0;
      else if(board[row][col]=='W' && move[col]==1) {
        find=1;
        white_step=row;
        break;
      }
    }
    row++;
  }
  int black_step=0;
  find=0;
  row=7;
  for(i=0;i<8;i++) {
    move[i]=1;
  }
  while(!find && row>=0) {
    int col;
    for(col=0;col<8;col++) {
      if(board[row][col]=='W') move[col]=0;
      else if(board[row][col]=='B' && move[col]==1) {
        find=1;
        black_step=8-row;
        break;
      }
    }
    row--;
  }
  if(white_step>black_step) {
    printf("A\n");
  } else {
    printf("B\n");
  }
  return 0;
}

#include<stdio.h>

int main()
{
    char str[9][9], my[8];
    int i, j, minB, minA, positB, positA, no1, no2, ans1, ans2;

    for(i=1; i<=8; i++)
    {
        gets(my);
        for(j=1; j<=8; j++)
        {
            str[i][j] = my[j-1];
        }
    }

    minB=7;
    minA=7;
    for(i=1; i<=8; i++)
    {
        no1 = 0;
        no2 = 0;
        positB=1;
        positA=8;
        for(j=1; j<=8; j++)
        {
            if(str[j][i] == 'B')
            {
                no1++;
                positB=j;
            }
            if(str[j][i] == 'W')
            {
                no2++;
                if(j<positA)
                    positA = j;
            }
        }
        printf("%d %d \n", no1, no2);

        if(no1>0 && no2==0)
        {
            ans1 = 8 - positB;
            if(minB>ans1)
                minB = ans1;
        }
        else if(no1==0 && no2>0)
        {
            ans2 = positA - 1;
            if(minA>ans2)
                minA = ans2;
        }
    }
    if(minA <= minB)
        printf("A");
    else
        printf("B");

    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    char board[8][9];
    int countr, countc;
    int W = 8, B = 8, WBuff = 0, BBuff = 0;
    for(countr = 0; countr < 8; countr++)
    {
        for(countc = 0; countc < 9; countc++)
        {
            scanf("%c", &board[countr][countc]);
        }
    }
    for(countc = 0; countc < 8; countc++)
    {
        for(countr = 0; countr < 8; countr++)
        {
            if(board[countr][countc] == 'W')
            {
                if(W>countr)
                    WBuff = countr;
            }
            if(board[countr][countc] == 'B')
            {
                if(B>(7-countr))
                    BBuff = 7 - countr;
            }
        }
        if((BBuff+WBuff)<8)
        {
            if(WBuff>0)
                W = WBuff;
            if(BBuff>0)
                B = BBuff;
        }
        WBuff = 0;
        BBuff = 0;
    }
    if(B<W)
        printf("B");
    else
        printf("A");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(){

  char Chess[8][8];
  int i,j ;
  int dist_A=0;
  int dist_B=0;

  for(i=0;i<8;i++)scanf("%s",Chess[i]);

  i=1;
  while(i<8 && dist_A==0){
     for(j=0;j<8;j++){
     if(Chess[i][j]=='W'&&Chess[i-1][j]!='B'){dist_A=i;break;}
     }
     i=i+1;
   }

  i=6;
  while(i>0 && dist_B==0){
     for(j=0;j<8;j++){
     if(Chess[i][j]=='B'&&Chess[i-1][j]!='W'){dist_B=7-i;break;}
     }
     i=i-1;
    }

  if(dist_B>=dist_A)printf("A");
  else
    printf("B");

return 0 ;
}

#include<stdio.h>
#include<stdlib.h>

int main(){

  char Chess[8][8];
  int i,j,k ;
  int dist_A=0;
  int dist_B=0;
  int B_exist=0;
  int A_exist=0;

  for(i=0;i<8;i++)scanf("%s",Chess[i]);

  i=1;
  while(i<8 && dist_A==0){
     for(j=0;j<8&&dist_A==0;j++){

       if(Chess[i][j]=='W'){
        for(k=0;k<i&&B_exist==0;k++){if(Chess[k][j]=='B')B_exist=1;}
        if(B_exist==0){dist_A=i;break;}
      }

     }

     B_exist=0;
     i=i+1;
   }
// printf("%d\n",dist_A);

  i=6;
  while(i>0 && dist_B==0){
     for(j=0;j<8;j++){
     if(Chess[i][j]=='B'){
        for(k=7;k>i;k--){if(Chess[k][j]=='W'){A_exist=1;break;}}
     if(A_exist==0){dist_B=8-i;break;}
     }
   }
     A_exist=0;
     i=i-1;
 }

 //printf("%d\n",dist_B);
  if(dist_B==0)printf("A");
  else{
       if(dist_A==0)printf("B");
       else{
             if(dist_B>=dist_A)printf("A");
             else
              printf("B");
           }
      }

return 0 ;
}

//http://codeforces.com/contest/592/problem/A

#include<stdio.h>
#include<stdlib.h>

int main(void){
    int i,j,trash;
    int bmin=10,wmin=10;
    int bm=0,wm=0;
    char a[8][8]={0};
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            scanf("%c",&a[i][j]);
        }
        scanf("%c",&trash);
    }

    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            printf("%c ",a[i][j]);
        }
        printf("\n");
    }

    for(j=0;j<8;j++){
        bm=0;
        wm=0;
        for(i=0;i<8;i++){
            if(a[i][j]=='.'){
                wm++;
            }
            else if(a[i][j]=='b'){
                wm=0;
                break;
            }
            else break;
        }
        for(i=7;i>=0;i--){
            if(a[i][j]=='.'){
                bm++;
            }
            else if(a[i][j]=='w'){
                bm=0;
                break;
            }
            else break;
        }
        if(bm<bmin){
            bmin=bm;
        }
        if(wm<wmin){
            wmin=wm;
        }
    }

    printf("%d %d\n",wmin ,bmin);

    if(wmin<=bmin){
        printf("A\n");
    }
    else{
        printf("B\n");
    }
    return 0;

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char board[8][8], x[10];
    int i, j, k, black = 10, white = 10;
    for (i = 0; i < 8; i++){
        scanf("%s", &x);
        for (j = 0; j < 8; j++) board[i][j] = x[j];
    }
    for (i = 0; i < 8; i++){
        for (j = 0; j < 8; j++){
            if (board[i][j] == 'B'){
                for (k = i+1; k < 8; k++) if (board[k][j] != '.') break;
                if ((k == 8) && ((7 - i) < black)) black = (7-i);
            }else if (board[i][j] == 'W'){
                for (k = i-1; k >= 0; k--) if (board[k][j] != '.') break;
                if ((k == -1) && (i < white)) white = i;
            }
        }
    }
    printf((white < black)?"A\n":"B\n");
    return 0;
}

/*A*/
#include<stdio.h>
#include<string.h>
int main()
{
	char chess[9][9];
	int A,B;
	int i,j;
	int p;
	int flag;
	//while(1)
	//{
		for(i=1;i<=8;i++)
		    scanf("%s",chess[i]);
		A=8;B=8;
		for(i=1;i<=8;i++)
		{
			for(j=0;j<8;j++)
			{
			    if(chess[i][j]=='W')
			    {
			    	flag=1;
			    	for(p=i-1;p>=1;p--)
			    	{
			    		if(chess[p][j]!='.')
			    		{
			    			flag=0;
			    			break;
						}
					}
					if(flag==1&&i<A)
					    A=i-1;
				}
				if(chess[i][j]=='B')
				{
					flag=1;
					for(p=i+1;p<=8;p++)
					{
						if(chess[p][j]!='.')
						{
							flag=0;
							break;
						}
					}
					if(flag==1&&(8-i)<B)
					    B=8-i;
				}
			}
		}
		if(A<=B)
		    printf("A\n");
		else
		    printf("B\n");
//	}
	return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(){

  char Chess[8][8];
  int i,j,k ;
  int dist_A=0;
  int dist_B=0;
  int B_exist=0;
  int A_exist=0;

  for(i=0;i<8;i++)scanf("%s",Chess[i]);

  i=1;
  while(i<8 && dist_A==0){
     for(j=0;j<8;j++){
       if(Chess[i][j]=='W'){
        for(k=0;k<i;k++){if(Chess[k][j]=='B'){B_exist=1;break;}}
        if(B_exist==0){dist_A=i-1;break;}
      }
     }
     B_exist=0;
     i=i+1;
   }

  i=6;
  while(i>0 && dist_B==0){
     for(j=0;j<8;j++){
     if(Chess[i][j]=='B'){
        for(k=7;k>i;k--){if(Chess[k][j]=='W'){A_exist=1;break;}}
     if(A_exist==0){dist_B=7-i;break;}
     }
   }
     A_exist=0;
     i=i-1;
 }

  if(dist_B>=dist_A)printf("A");
  else
    printf("B");

return 0 ;
}

#include<stdio.h>

int main()
{
    char str[9][9], my[8];
    int i, j, minB, minA, positB, positA, no1, no2, ans1, ans2,posita, positb;

    for(i=1; i<=8; i++)
    {
        gets(my);
        for(j=1; j<=8; j++)
        {
            str[i][j] = my[j-1];
        }
    }

    minB=7;
    minA=7;
    for(i=1; i<=8; i++)
    {
        no1 = 0;
        no2 = 0;
        positB=1;
        positb = 8;
        positA=8;
        posita = 1;
        for(j=1; j<=8; j++)
        {
            if(str[j][i] == 'B')
            {
                no1++;
                if(j<positb)
                    positb = j;
                positB=j;
            }
            if(str[j][i] == 'W')
            {
                no2++;
                if(j<positA)
                    positA = j;
                posita=j;
            }
        }

        if(no1>0 && no2==0)
        {
            ans1 = 8 - positB;
            if(minB>ans1)
                minB = ans1;
        }
        else if(no1==0 && no2>0)
        {
            ans2 = positA - 1;
            if(minA>ans2)
                minA = ans2;
        }

        else if(no1>0 && no2>0)
        {
            if(posita<positB)
            {
                ans1 = 8-positB;
                if(minB>ans1)
                    minB = ans1;
            }
             else if(positb>positA)
             {
                 ans2 = positA -1;
                 if(minA>ans2)
                    minA = ans2;
             }
        }
    }
    if(minA <= minB)
        printf("A");
    else
        printf("B");

    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{   char tabla[50][50];
    int beli[50][50];
    int crni[50][50];
    int a,b,c,d;
    int i;
    for(i=0;i<8;i++){
        gets(tabla[i]);
    }
   char *q=tabla[0];
   int beli_int=0;
   int beli_int1=0;
   int petlja_beli1=0;
   int petlja_beli;
   int brojac_belih=0;
   for(petlja_beli=0;petlja_beli<8;petlja_beli++){
        q=tabla[petlja_beli];
        for(beli_int=0;beli_int<8;beli_int++,q++){
   if(*q=='W'){
    beli[petlja_beli1++][beli_int1]=(petlja_beli+1)*10 + beli_int+1;
    brojac_belih++;
   }}
beli_int1=0;
   }

   int petlja_crni;
   int crni_int;
   int petlja_crni1=0;
   int crni_int1=0;
   int brojac_crnih=0;
   for(petlja_crni=0;petlja_crni<8;petlja_crni++){
        q=tabla[petlja_crni];
        for(crni_int=0;crni_int<8;crni_int++,q++){
   if(*q=='B'){
    crni[petlja_crni1++][crni_int1]=(petlja_crni+1)*10 + crni_int+1;
    brojac_crnih++;
   }
   }
crni_int1=0;
   }
int test=0;
for(test=0;test<brojac_crnih;test++){
  // printf("CRNI-%d\n",crni[test][0]);
}
for(test=0;test<brojac_belih;test++){
    //printf("BELI-%d\n",beli[test][0]);
}
int dobri_crni[50][50];
int dobri_beli[50][50];
int test_GD;
int test_GD1;
int broj_valid;
int nije_valid=0;
int crni_increaser=0;
for(test_GD1=0;test_GD1<brojac_crnih;test_GD1++){
        nije_valid=0;
        broj_valid=crni[test_GD1][0];
for(test_GD=0;test_GD<brojac_belih;test_GD++){
    if(broj_valid%10 == beli[test_GD][0]%10)
    {
        nije_valid=1;
        break;
    }
}
if(nije_valid == 1)
    continue;
else{
    dobri_crni[crni_increaser++][0]=broj_valid;
    nije_valid=0;
}
}
for(test=0;test<crni_increaser;test++){
   // printf("DOBRI CRNI-%d\n",dobri_crni[test][0]);
}
int beli_increaser=0;
for(test_GD1=0;test_GD1<brojac_belih;test_GD1++){
        nije_valid=0;
        broj_valid=beli[test_GD1][0];
for(test_GD=0;test_GD<brojac_crnih;test_GD++){
    if(broj_valid%10 == crni[test_GD][0]%10 && broj_valid/10>crni[test_GD][0]/10)
    {
        nije_valid=1;
        break;
    }
}
if(nije_valid == 1)
    continue;
else{
    dobri_beli[beli_increaser++][0]=broj_valid;
    nije_valid=0;
}}
for(test=0;test<beli_increaser;test++){
  // printf("DOBRI BELI-%d\n",dobri_beli[test][0]);
}
int sort;
int sort1;
int najveci_crni=dobri_crni[0][0];
for(sort=0;sort<crni_increaser-1;sort++){
    for(sort1=0;sort1<crni_increaser;sort1++){
        if(najveci_crni<dobri_crni[sort1][0]){
           najveci_crni=dobri_crni[sort1][0];
        }
    }
}
//printf("\n\n**NAJVECI CRNI%d",najveci_crni);
int najveci_beli=dobri_beli[0][0];
for(sort=0;sort<beli_increaser-1;sort++){
    for(sort1=0;sort1<beli_increaser;sort1++){

        if(najveci_beli>dobri_beli[sort1][0]){
           najveci_beli=dobri_beli[sort1][0];
        }
    }
}
//printf("\n\n**NAJVECI BELI%d",najveci_beli);
int zadnji_korak_b;
int zadnji_korak_c;
zadnji_korak_b=najveci_beli/10;
zadnji_korak_c=najveci_crni/10;
//printf("\n\nBELI - %d\nCRNI - %d",abs(1-zadnji_korak_b),abs(8-zadnji_korak_c));
if(abs(1-zadnji_korak_b)<=abs(8-zadnji_korak_c)){
printf("A");
}
else
    printf("B");
}

#include <stdio.h>
#include <stdlib.h>

main()
    {
        int i,j,na,nb,stepA,stepB;
        int Ax[64],Ay[64],Bx[64],By[64];
        char s[9];
        na = 0;
        nb = 0;
        for (i=0;i<8;i++)
            {
                scanf("%s",s);
                for (j=0;j<8;j++)
                    {
                        if (s[j]=='W')
                            {
                                Ax[na] = i;
                                Ay[na] = j;
                                na++;
                            }
                        else
                            {
                                if (s[j]=='B')
                                    {
                                        Bx[nb] = i;
                                        By[nb] = j;
                                        nb++;
                                    }
                            }
                    }
            }

        stepA = 10;
        for (i=0;i<na;i++)
            {
                //Chercher Ay[i] dans By
                j = 0;
                while ((j<nb) && ((By[j]!=Ay[i]) || ((By[j]==Ay[i]) && (Ax[i]<Bx[j])))) j++;
                if (j==nb) if (Ax[i]<stepA) stepA = Ax[i];

            }

        stepB = 10;
        for (i=0;i<nb;i++)
            {
                j = 0;
                while ((j<na) && ((Ay[j]!=By[i]) || ((Ay[j]==By[i]) && (Ax[j]<Bx[i])))) j++;
                if (j==na) if ((7-Bx[i])<stepB) stepB = 7 - Bx[i];
            }
        if (stepA<stepB) printf("A");
        else printf("B");
    }

#include<stdio.h>
#include<math.h>
int main()
{   char tabla[50][50];
    int beli[50][50];
    int crni[50][50];
    int a,b,c,d;
    int i;
    for(i=0;i<8;i++){
        gets(tabla[i]);
    }
   char *q=tabla[0];
   int beli_int=0;
   int beli_int1=0;
   int petlja_beli1=0;
   int petlja_beli;
   int brojac_belih=0;
   for(petlja_beli=0;petlja_beli<8;petlja_beli++){
        q=tabla[petlja_beli];
        for(beli_int=0;beli_int<8;beli_int++,q++){
   if(*q=='W'){
    beli[petlja_beli1++][beli_int1]=(petlja_beli+1)*10 + beli_int+1;
    brojac_belih++;
   }}
beli_int1=0;
   }

   int petlja_crni;
   int crni_int;
   int petlja_crni1=0;
   int crni_int1=0;
   int brojac_crnih=0;
   for(petlja_crni=0;petlja_crni<8;petlja_crni++){
        q=tabla[petlja_crni];
        for(crni_int=0;crni_int<8;crni_int++,q++){
   if(*q=='B'){
    crni[petlja_crni1++][crni_int1]=(petlja_crni+1)*10 + crni_int+1;
    brojac_crnih++;
   }
   }
crni_int1=0;
   }
int test=0;
for(test=0;test<brojac_crnih;test++){
  // printf("CRNI-%d\n",crni[test][0]);
}
for(test=0;test<brojac_belih;test++){
    //printf("BELI-%d\n",beli[test][0]);
}
int dobri_crni[50][50];
int dobri_beli[50][50];
int test_GD;
int test_GD1;
int broj_valid;
int nije_valid=0;
int crni_increaser=0;
for(test_GD1=0;test_GD1<brojac_crnih;test_GD1++){
        nije_valid=0;
        broj_valid=crni[test_GD1][0];
for(test_GD=0;test_GD<brojac_belih;test_GD++){
    if(broj_valid%10 == beli[test_GD][0]%10)
    {
        nije_valid=1;
        break;
    }
}
if(nije_valid == 1)
    continue;
else{
    dobri_crni[crni_increaser++][0]=broj_valid;
    nije_valid=0;
}
}
for(test=0;test<crni_increaser;test++){
   // printf("DOBRI CRNI-%d\n",dobri_crni[test][0]);
}
int beli_increaser=0;
for(test_GD1=0;test_GD1<brojac_belih;test_GD1++){
        nije_valid=0;
        broj_valid=beli[test_GD1][0];
for(test_GD=0;test_GD<brojac_crnih;test_GD++){
    if(broj_valid%10 == crni[test_GD][0]%10 && broj_valid/10>crni[test_GD][0]/10)
    {
        nije_valid=1;
        break;
    }
}
if(nije_valid == 1)
    continue;
else{
    dobri_beli[beli_increaser++][0]=broj_valid;
    nije_valid=0;
}}
for(test=0;test<beli_increaser;test++){
  // printf("DOBRI BELI-%d\n",dobri_beli[test][0]);
}
int sort;
int sort1;
int najveci_crni=dobri_crni[0][0];
for(sort=0;sort<crni_increaser-1;sort++){
    for(sort1=0;sort1<crni_increaser;sort1++){
        if(najveci_crni<dobri_crni[sort1][0]){
           najveci_crni=dobri_crni[sort1][0];
        }
    }
}
printf("\n\n**NAJVECI CRNI%d",najveci_crni);
int najveci_beli=dobri_beli[0][0];
for(sort=0;sort<beli_increaser-1;sort++){
    for(sort1=0;sort1<beli_increaser;sort1++){

        if(najveci_beli>dobri_beli[sort1][0]){
           najveci_beli=dobri_beli[sort1][0];
        }
    }
}
printf("\n\n**NAJVECI BELI%d",najveci_beli);
int zadnji_korak_b;
int zadnji_korak_c;
zadnji_korak_b=najveci_beli/10;
zadnji_korak_c=najveci_crni/10;
//printf("\n\nBELI - %d\nCRNI - %d",abs(1-zadnji_korak_b),abs(8-zadnji_korak_c));
if(abs(1-zadnji_korak_b)<=abs(8-zadnji_korak_c)){
printf("A");
}
else
    printf("B");
}

#include<stdio.h>
int main(){
int i,j,wmoves,bmoves,wrow,wcol,brow,bcol;
char arr[8][8];
int warr[8];
int barr[8];
int bmin,wmin;
for(i=0; i<8; i++)
    scanf("%s",arr[i]);
    for(i=0; i<8; i++)
        {
            warr[i]=0;
            barr[i]=0;
        }
for(i=0; i<8; i++){
for(j=0; j<8; j++){

    if(arr[i][j]=='W'){
            if(warr[j]==0 &&barr[j]==0)
            warr[j]=i;
            if(barr[j]>0)
                barr[j]=0;

        }
     if(arr[i][j]=='B')
            {
                if(barr[j]==0)
                    barr[j]++;
                else
                    barr[j]=1;
            }
      if(arr[i][j]=='.'){
        if(barr[j]>0)
            barr[j]++;
      }
}
}
bmin=0;
wmin=0;
for(i=0; i<8; i++){
    if(wmin==0&&warr[i]>0)
      wmin=warr[i];
    else if(warr[i]>0&&warr[i]<wmin)
        wmin=warr[i];
 if(bmin==0&&barr[i]>0)
      bmin=barr[i];
  else if(barr[i]>0&&barr[i]<bmin)
        bmin=barr[i];
}
if(wmin<=bmin-1)
    printf("A\n");
else
    printf("B\n");
return 0;
}

#include <stdio.h>

int main(void)
{
    char board[8][8];

    int i, j;
    for (i = 0; i < 8; i++)
        for (j = 0; j < 8; j++)
            scanf(" %c", &board[i][j]);

    int mina = 10, minb = 10;
    for (i = 0; i < 8; i++)
    {
        for (j = 0; j < 8; j++)
        {
            if (board[j][i] == 'B')
                break;
            else if (board[j][i] == 'W')
            {
                if (mina > j)
                    mina = j;
                 break;
            }
        }

        int k = 7;
        for (; k >= j; k--)
        {
            if (board[k][i] == 'W')
                break;
            else if (board[k][i] == 'B')
            {
                if (minb > 7-k)
                    minb = 7-k;
                 break;
            }
        }
    }
    printf("%c", mina < minb ? 'A' : 'B');
    return 0;
}

/*A*/
#include<stdio.h>
#include<string.h>
int main()
{
	char chess[9][9];
	int A,B;
	int i,j;
	int p;
	int flag;
	//while(1)
	//{
		for(i=1;i<=8;i++)
		    scanf("%s",chess[i]);
		A=8;B=8;
		for(i=1;i<=8;i++)
		{
			for(j=0;j<8;j++)
			{
			    if(chess[i][j]=='W')
			    {
			    	flag=1;
			    	for(p=i-1;p>=1;p--)
			    	{
			    		if(chess[p][j]!='.')
			    		{
			    			flag=0;
			    			break;
						}
					}
					if(flag==1&&i<A)
					    A=i;
				}
				if(chess[i][j]=='B')
				{
					flag=1;
					for(p=i+1;p<=8;p++)
					{
						if(chess[p][j]!='.')
						{
							flag=0;
							break;
						}
					}
					if(flag==1&&(8-i)<B)
					    B=8-i;
				}
			}
		}
		if(A<=B)
		    printf("A\n");
		else
		    printf("B\n");
//	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int Free_Way(const int *matrix,int col,int str,int derect)
{
    int i,j,flag=0;
    if(derect==1)
        for(i=str-1;i>=0;i--) {
            if (matrix[i*8+col]!=0) {
                flag=1;
                break;
            }
        }
    else
        for(i=str+1;i<8;i++)
            if (matrix[i*8+col]!=0) {
                flag=1;
                break;
            }
    return !flag;
}

int main()
{
    int sq[8][8],i,j,rw,rb;
    char str[8];
    for(i=0;i<8;i++) {
        scanf("%s",str);
        for(j=0;j<8;j++)
            if (str[j]!='.')
                if (str[j]=='W')
                    sq[i][j]=1;
                else
                    sq[i][j]=-1;
            else
                sq[i][j]=0;
    }
    for(i=1;i<8;i++)
        for(j=0;j<8;j++)
            if ((sq[i][j]==1)&&(Free_Way(&sq[0][0],j,i,1))) {
                rw=i;
                break;
            }
    for(i=7;i>=0;i--)
        for(j=0;j<8;j++)
            if ((sq[i][j]==-1)&&(Free_Way(&sq[0][0],j,i,-1))) {
                rb=8-i;
                break;
            }
    if (rw<=rb)
        printf("A");
    else
        printf("B");

    return 0;
}

#include "stdio.h"
#include "string.h"

int main(int argc, char* argv[])
{
	char s[10];
	int i,j,ans=8,ans2=-1;
	for(i=0;i<8;i++)
	{
		scanf("%s",s);
	}

	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			if(s[j]=='B')
			{
				ans=i+1;
				if(i>ans)
					ans=i+1;
			}
			if(s[j]=='W')
			{
				ans2=i+1;
				if(i<ans2)
					ans2=i+1;
			}
		}
	}
	if(ans2>(8-ans))
		printf("B\n");
	else
		printf("A\n");

	return 0;
}