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. 

<image>

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.

Input

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.

Output

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.

Examples

Input

........
........
.B....B.
....W...
........
..W.....
........
........


Output

A


Input

..B.....
..W.....
......B.
........
.....W..
......B.
........
........


Output

B

Note

In 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.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;


public class CodeForces {

    
    private static boolean sameset(int a, int b, int[] uf) {
        
        return find(a,uf) == find(b,uf);
    }

    private static void union(int a, int b, int[] uf) {
        uf[find(a,uf)] = find(b,uf);
    }

    private static int find(int a, int[] uf) {
        if(a == uf[a])  return a;
        int root = find(uf[a],uf);
        uf[a] = root;
        return root;
    }

    private static void BFS(int i, int[][] G, int[][] path) {
       // System.out.println("source vertex "+i);
        int[] v = new int[G.length]; // current maximum dist in u---v path
        ArrayDeque<Integer> A = new ArrayDeque();
        A.add(i);
        while(A.isEmpty() == false){
            int u = A.pop();
            //System.out.println("for node "+u);
            for(int a=0;a<v.length;a++){
                if(G[u][a] > 0 && v[a]==0 && a!=i){//edge in MST, later make faster
                    //System.out.println(a+" is and edge from "+u);
                    if(G[u][a] > v[u]){
                        //System.out.println(" and it incrases the sub path max ");
                        v[a] = G[u][a];
                    }
                    else    v[a] = v[u];
                    path[i][a] = v[a];
                    path[a][i] = v[a];
                   // System.out.println("finally path from "+i+" to "+a+" is "+path[i][a]);
                    
                    A.add(a);
                }
            }
        }
    }

    private static int numd(int x) {
        Double xx = Double.parseDouble(String.valueOf(x));
        int y = (int) Math.log10(xx);
        return (y+1);
       
         
        
    }

    private static String primeFactor(int n, boolean[] x) {
        String ans = "";
        for(int i=2;i<x.length;i++){
            if(i*i > n) break;
            if(x[i]){
                //System.out.println("testing prome "+i);
                while(n!=1 && i*i <= n){
                    while(n%i==0){
                       // System.out.println(i+" can divide "+n);
                        if(ans.equals(""))  ans=String.valueOf(i);
                        else    ans+=" x "+i;
                        n/=i;
                    }
                    break;
                }
            }
        }
        if(n!=1){
           // System.out.println("Remainig "+n);
            if(ans.equals(""))  ans=String.valueOf(n);
            else    ans+=" x "+n;
        }
        return ans;
    }

    private static String solve(String s) {
        
        
        
        return null;
    }

    //counts the number of divisors using the fundamental theorem of arithmetic
    private static int getDivisorCount(int n) {
        
        int count = 1;
        
        int tmp = n;
        
        for(int i=2;i*i<=n;i=(i==2?3:i+2)){
            
            //System.out.println(i+" is odd");
            
            int pow = 0;
            
            while(n%i==0){
                pow+=1;
                n/=i;
            }
            
            if(pow != 0){
                ///System.out.println(i+" must be a prime");
                count*=(pow+1);
            }
        }
        
        if(n!=1){
            //System.out.println(n+" is the last prime factor");
            count*=2;
        }
        
        //System.out.println("number of divisors of "+tmp+" is "+count);
        return count;
    }

    private static long nchoosek(int n, int k) {
        
        long prod = 1;
        int j = 1;
        
        int st = Math.max(n-k, k)+1;
        int ed = Math.min(n-k, k);
        
        for(int i=st;i<=n;i++){
            for(;j<=ed;j++){
                if(prod%j==0)   prod/=j;
                else break;
            }
            prod*=i;
        }
        
        for(;j<=ed;j++){
            prod/=j;
        }
        
        return prod;
    }
    
    //related to extgcd problems
    private static boolean check() {
        //System.out.println(a+" "+b+" "+c1+" "+c2);
        if(n%ibgcd(a,b)!=0) {
           // System.out.println("not possible");
            return false;
        }
        
        extgcd(a,b);
        long gcd=0,m1=x,m2=y;
        gcd=d;
        m1*=(n/d);
        m2*=(n/d);
        a/=d;
        b/=d;
        
        double f1 = (m1/b);f1*=-1;
        double f2 = (m2/a);
        long le = (long) Math.ceil(f1);
        long re = (long) Math.floor(f2);
        if(le > re) return false;
        long cf=c1*b-c2*a;
        if(cf*le < cf*re){
        
            x = m1+b*le;
            y = m2-a*le;
        }else{
            x = m1+b*re;
            y = m2-a*re;
        }
        //System.out.println("upper and lower are "+le+" "+re);
        
        
        return true;
    }

    private static void extgcd(long a, long b) {
        
        if(b==0){
            x=1;y=0;d=a;return;
        }
        extgcd(b,a%b);
        long x1 = y;
        long y1 = x-(a/b)*y;
        x=x1;
        y=y1;
    }

    private static void floyd_cycle(int z, int I, int m, int x0) {
        
        int tor = func(z,I,m,x0);
        int har = func(z,I,m,tor); //one step ahead of tor
        //System.out.println("initial value for tor and har "+tor+" "+har);
        
        while(tor!=har){
            tor = func(z,I,m,tor);
            har = func(z,I,m,har);
            har = func(z,I,m,har);
            //System.out.println("tor and har "+tor+" "+har);
        }
        
        //at r-x%m now
        int x = 0;
        har = tor;
        tor = x0;
        
        while(har!=tor){
            
            tor = func(z,I,m,tor);
            har = func(z,I,m,har);
            x+=1;
            //System.out.println("findind x tor and har "+tor+" "+har);
        }
        
        //now at first reapting node
        int lam = 1;
        har = func(z,I,m,tor);
        
        while(har!=tor){
            har = func(z,I,m,har);
            lam+=1;
            //System.out.println("finding lam, tor and har "+tor+" "+har);
        }
        
       // return new Pair(z,lam);
    }

   private static int func(int z, int I, int m, int x0) {
        return ((z*x0)%m+I%m)%m;
    }

    private static void dfs(int a, int[][] d, int[] v,int[] p) {
        
        v[a] = 1;
        for(int i=0;i<v.length;i++){
            if(i!=a && d[i][a]!=0){
                if(v[i]==0){
                   // System.out.println("dfsing "+i);
                    p[i]=a;
                    dfs(i,d,v,p);
                }else if(p[a] != i && a<i){
                   // System.out.println(a+" and "+i+" causing cycle"+p[i]);
                    cycle=true;
                }
            }
        }
        
    }

    private static void dolve(int x, int[] a) {
        //find sors of x
        int cnt = 0;
        for(int i=2;i<=Math.sqrt(x);i=(i==2?3:i+2)){
            int pow = 0;
            while(x%i==0){
                x/=i;
                pow+=1;
            }
            if(pow!=0){
                for(int j=1;j<=pow;j++){
                    long f = (long) Math.pow(i, j);
                    
                    if(f<a.length){
                        a[Integer.parseInt(String.valueOf(f))]=1;
                        //System.out.println("ading "+Integer.parseInt(String.valueOf(f)));
                    }
                    
                }
            }
        }
        
        if(x!=1){
            //System.out.println("ading "+x);
            if(x<a.length)  a[x]=1;
        }
    }

    

    private static long search(long max, long tmp, long a, long b) {
        
        long lo = 0;
        long hi = max;
        
        while(lo < hi){
            
            long mid = (lo+hi)>>1;
            
            long k = mid*a;
            k/=b;
            if(k==tmp)  hi=mid;
            else    lo = mid+1;
        }
        
        return lo;
    }

    

    private static int palindrome(int i, int j, String s, int[][] dp) {
        //if(i > j)   System.out.println("PLEASE STOP");
        int ret = 0;
        if(i==j)    {
            dp[i][j]=ret;
            return ret;
        }
        if(i+1==j && s.charAt(i)==s.charAt(j))  {
            dp[i][j]=ret;
            return ret;
        }
        if(i+1==j && s.charAt(i)!=s.charAt(j))  {
            
            ret = 1;
            dp[i][j]=ret;
            return ret;
        }
        
        if(s.charAt(i) == s.charAt(j)){
            
            ret = dp[i+1][j-1]==-1 ? palindrome(i+1,j-1,s,dp) : dp[i+1][j-1];
            //ret = 2+ sub;
            dp[i][j]=ret;
            return ret;
        }
        else{
            int sub1 = dp[i+1][j]==-1 ? palindrome(i+1,j,s,dp) : dp[i+1][j];
            int sub2 = dp[i][j-1]==-1 ? palindrome(i, j-1,s,dp) : dp[i][j-1];
            int sub3 = dp[i+1][j-1]==-1 ? palindrome(i+1,j-1,s,dp) : dp[i+1][j-1];
            
            ret = Math.min(sub1, sub2);
            ret = Math.min(ret, sub3);
            ret+=1;
            dp[i][j]=ret;
            return ret;
        }
        //return 0;
    }

    private static ArrayList<Integer> dfs_p(int a, int[] v, int[][] g, ArrayList<Integer> A) {
        
        v[a]=1;
        A.add(a);
        
        for(int i=0;i<v.length;i++){
            if(i!=a){
                if(g[a][i]==1 && v[i]==0){
                    //System.out.println("picking "+i);
                    return dfs_p(i, v, g, A);
                }
            }
        }
        return A;
        
    }

    private static double qs(double lo, double hi, Pair[] S) {
        
        double ans = -1.0;
        
        for(int i=0;i<1000;i++){
            double mid = (lo+hi)/2.0;
            //System.out.println("using a radius of "+mid);
            ans=mid;
            long tmp = 0;
            for(int j=0;j<S.length;j++){
                if(mid < S[j].d)    break;
                else{
                    tmp+=Long.parseLong(String.valueOf(S[j].p));
                }
            }
            //System.out.println("pop is "+tmp);
            
            if(tmp >= 1000000){
                hi=mid;
            }
            else if(tmp < 1000000){
                lo=mid;
            }
            
        }
        
       // System.out.println("usig ans os "+ans);
        //check again
        long tmp = 0;
        for(int i=0;i<S.length;i++){
            double d = Double.parseDouble(String.format( "%.7f", S[i].d ));
            ans = Double.parseDouble(String.format( "%.7f", ans ));
            //System.out.println(d+" "+ans);
            if(d > ans)    break;
            else{
                tmp += S[i].p;
            }
        }
        
        if(tmp >= 1000000)  return ans;
        
        
        
        return -1.0;
    }

   

    static class Node{
        
        int d=-1;
        long num;
        public Node(int a,long c){
            this.d = a;
            
            this.num = c;
            
        }
    }
    
    static class Edge{
        
        String d;
        int p;//ids of nodes
        int q;
        public Edge( String x1, int y1, int w){
            
            this.d = x1;
            this.p = y1;
            this.q = w;
        }
    }
    
    //simple sieve
    static boolean[] getPrimes(int n){
        
        boolean[] ret = new boolean[n+1];
        Arrays.fill(ret, true);
        
        ret[0] = ret[1] = false;
        
        for(int i=2;i*i <= n; i++){
            
            if(ret[i]){
                
                for(int j=i*i;j<=n;j+=i){
                    
                    ret[j]=false;
                }
            }
        }
        
        return ret;
    }
   
    static long ibgcd(long a, long b){
        
        while(b > 0){
            long r = a%b;
            a=b;
            b=r;
        }
        return a;
    }
    
    //for extgcd
    static long x,y,d; //output and gdc
    static long c1,c2,a,b,n; // inputs
    //static boolean[] p = getPrimes(5000001);
    
    static class Pair{
        double d ;
        int x;
        int y;
        int p;
        public Pair(int a, int f, int p){
            this.x = a;
            this.y = f;
            this.p=p;
            //compute the radius or euclidean distance
            double r = Math.pow(this.x, 2) + Math.pow(this.y, 2);
            this.d = Math.sqrt(r);
            
        }
    }
    
    static boolean cycle = false;
    
    static Stack<Integer> stack;
    static int[] dfs_low;
    static int[] dfs_num;
    static int timer;
    static int[] visit;
    
    static int[] string_match_basic(String S){
        
        int n = S.length();
        int[] L = new int[n];
        
        int index = 0;
        L[index] = 0; //base case
        
        while(index != n-1){
            
            int d = L[index];
            
            //System.out.println("at "+index+" is "+L[index]);
            
            while(S.charAt(d) != S.charAt(index+1) && d >0){
                d = L[d-1];
            }
            
            L[index+1] = S.charAt(d)==S.charAt(index+1) ? d+1 : 0;
            
            index+=1;
        }
        return L;
    }
    
    
    
    
    
    public static void main(String[] args) throws IOException {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new PrintWriter(System.out));
        //Scanner sc = new Scanner(System.in);
  
       
        HashMap<Integer, Integer> HA = new HashMap();
        HashMap<Integer, Integer> HB = new HashMap();
        
        int[] la=new int[8],lb=new int[8];
        Arrays.fill(la,-1);Arrays.fill(lb,-1);
        char[][] dp = new char[8][8];
        for(int i=0;i<8;i++){
            String in = br.readLine();
            for(int j=0;j<8;j++){
                dp[i][j] = in.charAt(j);
            }
        }
        
        //fill la
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(dp[i][j]=='B' && la[j]==-1)  la[j]=i;
            }
            
        }
        
        //fill lb
        for(int i=7;i>=0;i--){
            for(int j=0;j<8;j++){
                if(dp[i][j]=='W' && lb[j]==-1)  lb[j]=i;
            }
        }
        
        for(int i=0;i<8;i++){
            //System.err.println("col "+i+" la "+la[i]+" lb "+lb[i]);
        }
        
        int ma=1000, mb=1000;
        
        //find ma
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(dp[i][j]=='W' && (la[j]==-1||la[j]>i) && i<ma)   {
                    ma=i;
                    //System.out.println("at "+i+" "+j+" ma "+ma);
                }
            }
        }
        if(ma==1000)    ma=-1;
        
        //find mb
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(dp[i][j]=='B' && (lb[j]==-1||lb[j]<i) && (7-i)<mb)   {
                    mb=7-i;
                    //System.out.println("at "+i+" "+j+" mb "+mb);
                }
            }
        }
        if(mb==1000)    mb=-1;
        
        if(ma==-1)  bw.append("B\n");
        else if(mb==-1) bw.append("A\n");
        else if(ma<=mb) bw.append("A\n");
        else bw.append("B\n");
        
        bw.close();
    }
}