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.*;
import java.util.*;

public class Main {
    private final static InputReader ir = new InputReader(System.in);
    private final static OutputWriter ow = new OutputWriter(System.out);
    private final static int INF = Integer.MAX_VALUE;
    private final static int NINF = Integer.MIN_VALUE;
    private final static double PI = Math.PI;

    public static void main(String[] args) throws IOException {
        try {
            task();
        } finally {
            boolean exc = false;
            try {
                ir.close();
            } catch (IOException e) {
                e.printStackTrace();
                exc = true;
            }
            try {
                ow.close();
            } catch (IOException e) {
                e.printStackTrace();
                exc = true;
            }
            if (exc) System.exit(1);
        }
    }

    private static void task() throws IOException {
        int w = 8, b = 8;
        byte[][] field = new byte[8][8];
        for (int i = 0; i < 8; ++i) {
            String line = ir.nextLine(8);
            for (int j = 0; j < 8; ++j) {
                if (line.charAt(j) == 'W') {
                    field[i][j] = 1;
                } else if (line.charAt(j) == 'B'){
                    field[i][j] = 2;
                }
            }
        }

        for (int i = 0; i < 8; ++i) {
            for (int j = 0; j < 8; ++j) {
                if (field[i][j] == 1) {
                    boolean f = false;
                    for (int h = i - 1; h >= 0; --h)
                        if (field[h][j] == 2)
                            f = true;
                    if (i < w && !f) w = i;
                } else if (field[i][j] == 2) {
                    boolean f = false;
                    for (int h = i + 1; h < 8; ++h)
                        if (field[h][j] == 1)
                            f = true;
                    if (8 - i - 1 < b && !f) b = 8 - i - 1;
                }
            }
        }
        //ow.println(w + " " + b);
        if (w <= b) ow.print("A");
        else ow.print("B");

    }

    private static int max(int... objects) {
        if (objects.length == 0)
            throw new IllegalArgumentException("objects.length == 0");
        int max = objects[0];
        for (int i = 1; i < objects.length; ++i) {
            if (max < objects[i])
                max = objects[i];
        }
        return max;
    }

    private static int min(int... objects) {
        if (objects.length == 0)
            throw new IllegalArgumentException("objects.length == 0");
        int min = objects[0];
        for (int i = 1; i < objects.length; ++i) {
            if (min > objects[i])
                min = objects[i];
        }
        return min;
    }

    private static long pow(int x, int n) {
        if (x == 0) return 0;
        if (x == 1 || n == 0) return 1;
        if (x == 2) return x << (n - 1);
        if (n == 1) return x;
        long t = pow(x, n / 2);
        if (n % 2 == 0) return t * t;
        else return t * t * x;
    }

    private static int abs(int a) {
        return (a >= 0 ? a : -a);
    }
}

class SQRTDecomposition {
    private int[] array;
    private int len;
    private int[] max;
    private int[] min;

    public SQRTDecomposition(int[] arr, boolean useIt) {
        if (useIt)
            array = arr;
        else {
            array = new int[arr.length];
            System.arraycopy(arr, 0, array, 0, arr.length);
        }
        len = (int) Math.sqrt(array.length) + 1;
        max = new int[len];
        min = new int[len];
        for (int i = 0; i < array.length; ++i) {
            max[i / len] = min[i / len] = array[i];
        }
        for (int i = 0; i < array.length; ++i) {
            max[i / len] = Math.max(max[i / len], array[i]);
            min[i / len] = Math.min(min[i / len], array[i]);
        }
    }

    public int get(int i) {
        if (i <= 0 || i >= array.length)
            throw new IndexOutOfBoundsException("Index: " + i);
        return array[i];
    }

    public int length() {
        return array.length;
    }

    public int max(int l, int r) {
        int cl = l / len, cr = r / len;
        int m = array[l];
        if (cl == cr) {
            for (int i = l; i <= r; ++i) {
                if (array[i] > m) m = array[i];
            }
        } else {
            for (int i = l, end = (cl + 1) * len - 1; i <= end; ++i)
                if (array[i] > m) m = array[i];
            for (int i = cl + 1; i <= cr - 1; ++i)
                if (max[i] > m) m = max[i];
            for (int i = cr * len; i <= r; ++i)
                if (array[i] > m) m = array[i];
        }
        return m;
    }

    public int min(int l, int r) {
        int cl = l / len, cr = r / len;
        int m = array[l];
        if (cl == cr) {
            for (int i = l; i <= r; ++i) {
                if (array[i] < m) m = array[i];
            }
        } else {
            for (int i = l, end = (cl + 1) * len - 1; i <= end; ++i)
                if (array[i] < m) m = array[i];
            for (int i = cl + 1; i <= cr - 1; ++i)
                if (min[i] < m) m = min[i];
            for (int i = cr * len; i <= r; ++i)
                if (array[i] < m) m = array[i];
        }
        return m;
    }
}

class InputReader implements AutoCloseable {
    private final InputStream in;
    private int capacity;
    private byte[] buffer;
    private int len = 0;
    private int cur = 0;

    public InputReader(InputStream stream) {
        this(stream, 100_000);
    }

    public InputReader(InputStream stream, int capacity) {
        this.in = stream;
        this.capacity = capacity;
        buffer = new byte[capacity];
    }

    private int read() {
        if (cur >= len) {
            try {
                cur = 0;
                len = in.read(buffer, 0, capacity);
                if (len <= 0)
                    return -1;
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }
        return buffer[cur++];
    }

    private boolean isSpace(int c) {
        return c == ' ' || isEscape(c);
    }

    private boolean isEscape(int c) {
        return c == '\n' || c == '\t' || c == '\r' || c == -1;
    }

    private int readSkipSpace() {
        int c;
        do {
            c = read();
        } while (isSpace(c));
        return c;
    }

    int nextInt() {
        int c = readSkipSpace();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res = res * 10 + c - '0';
            if (res < 0)
                throw new InputMismatchException();
            c = read();
        } while (!isSpace(c));
        res *= sgn;
        return res;
    }

    public long nextLong() {
        int c = readSkipSpace();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res = res * 10 + c - '0';
            if (res < 0)
                throw new InputMismatchException();
            c = read();
        } while (!isSpace(c));
        res *= sgn;
        return res;
    }

    int nextChar() {
        return readSkipSpace();
    }

    String nextLine(int initialCapacity) {
        StringBuilder res = new StringBuilder(initialCapacity);
        int c = readSkipSpace();
        do {
            res.append((char) (c));
            c = read();
        } while (!isEscape(c));
        return res.toString();
    }

    @Override
    public void close() throws IOException {
        in.close();
    }
}

class OutputWriter implements Flushable, AutoCloseable {
    private byte[] buf;
    private int capacity;
    private int count;
    private OutputStream out;

    public OutputWriter(OutputStream stream) {
        out = stream;
        capacity = 10_000;
        buf = new byte[capacity];
    }

    public OutputWriter(OutputStream stream, int capacity) {
        if (capacity <= 0)
            throw new IllegalArgumentException("capacity <= 0");
        out = stream;
        this.capacity = capacity;
        buf = new byte[capacity];
    }

    public void write(int b) throws IOException {
        if (count >= buf.length)
            flushBuffer();
        buf[count++] = (byte) b;
    }

    public void write(byte[] bytes, int off, int len) throws IOException {
        if (len >= buf.length) {
            flushBuffer();
            out.write(bytes, off, len);
            return;
        }
        if (len > buf.length - count)
            flushBuffer();
        System.arraycopy(bytes, off, buf, count, len);
        count += len;
    }

    public void write(byte[] bytes) throws IOException {
        write(bytes, 0, bytes.length);
    }

    public void print(String str) throws IOException {
        write(str.getBytes());
    }

    public void println() throws IOException {
        print("\n");
    }

    public void print(Object object) throws IOException {
        print(object.toString());
    }

    public void println(Object object) throws IOException {
        print(object.toString());
        println();
    }

    public void print(int... ints) throws IOException {
        print(" ", ints);
    }

    public void println(int... ints) throws IOException {
        print(ints);
        println();
    }

    public void println(String separator, int... ints) throws IOException {
        print(separator, ints);
        println();
    }

    public void print(String separator, int... ints) throws IOException {
        if (ints.length == 0) throw new IllegalArgumentException("ints.length == 0");
        for (int i = 0; i < ints.length; ++i) {
            if (i != 0) print(separator);
            print(ints[i]);
        }
    }

    private void flushBuffer() throws IOException {
        if (count > 0) {
            out.write(buf, 0, count);
            count = 0;
        }
    }

    @Override
    public void flush() throws IOException {
        flushBuffer();
        out.flush();
    }

    @Override
    public void close() throws IOException {
        flush();
        out.close();
    }
}





