Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"reflect"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func scanBoard() [][]int {
	ret := make([][]int, 8)
	for k := range ret {
		ret[k] = make([]int, 8)
		for l := range ret[k] {
			ret[k][l] = 0
		}
	}
	for i := 0; i < 8; i++ {
		scanner.Scan()
		row := strings.Split(scanner.Text(), "")
		if reflect.DeepEqual(row, []string{}) {
			break
		}
		for j := 0; j < 8; j++ {
			ret[i][j], _ = strconv.Atoi(row[j])
		}
	}
	return ret
}

var emptyBoard = [][]int{{0,0,0,0,0,0,0,0},
						 {0,0,0,0,0,0,0,0},
						 {0,0,0,0,0,0,0,0},
	                     {0,0,0,0,0,0,0,0},
	                     {0,0,0,0,0,0,0,0},
	                     {0,0,0,0,0,0,0,0},
	                     {0,0,0,0,0,0,0,0},
	                     {0,0,0,0,0,0,0,0}}

func main() {
	for {
		var board [][]int
		var ans string
		if board = scanBoard(); reflect.DeepEqual(board, emptyBoard) {
			break
		}
		// fmt.Println(board)
		for i := 0; i < 7; i++ {
			for j := 0; j < 7; j++ {
				if board[i][j] == 1 && board[i+1][j] == 1 && board[i][j+1] == 1 && board[i+1][j+1] == 1 {
					ans = "A"
				}
			}
		}
		for i := 0; i < 5; i++ {
			for j := 0; j < 8; j++ {
				if board[i][j] == 1 && board[i+1][j] == 1 && board[i+2][j] == 1 && board[i+3][j] == 1 {
					ans = "B"
				}
			}
		}
		for i := 0; i < 8; i++ {
			for j := 0; j < 5; j++ {
				if board[i][j] == 1 && board[i][j+1] == 1 && board[i][j+2] == 1 && board[i][j+3] == 1 {
					ans = "C"
				}
			}
		}
		for i := 0; i < 6; i++ {
			for j := 0; j < 7; j++ {
				if board[i][j+1] == 1 && board[i+1][j] == 1 && board[i+1][j+1] == 1 && board[i+2][j] == 1 {
					ans = "D"
				}
			}
		}
		for i := 0; i < 7; i++ {
			for j := 0; j < 6; j++ {
				if board[i][j] == 1 && board[i][j+1] == 1 && board[i+1][j+1] == 1 && board[i+1][j+2] == 1 {
					ans = "E"
				}
			}
		}
		for i := 0; i < 7; i++ {
			for j := 0; j < 6; j++ {
				if board[i][j+1] == 1 && board[i][j+2] == 1 && board[i+1][j] == 1 && board[i+1][j+1] == 1 {
					ans = "G"
				}
			}
		}
		for i := 0; i < 6; i++ {
			for j := 0; j < 7; j++ {
				if board[i][j] == 1 && board[i+1][j] == 1 && board[i+1][j+1] == 1 && board[i+2][j+1] == 1 {
					ans = "F"
				}
			}
		}
		fmt.Println(ans)
	}
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 8;

int main(void){
    for(vs t(N);;){
        int l = N, r = 0, u = N, d = 0;
        rep(i, N){
            if(!(cin >> t[i])) return 0;
            
            rep(j, N) if(t[i][j] == '1')
                l = min(l, j), r = max(r, j), 
                u = min(u, i), d = max(d, i);
        }
        int w = r - l + 1, h = d - u + 1;

        cout << (w == 4 ? 'C':h == 4 ? 'B':w == 2 ? h == 2 ? 'A': t[u][l] == '1' ? 'F':'D': t[u][l] == '1' ? 'E':'G') << endl;
    }
 
    return 0;
}

C++: #include <iostream>
#include <array>
#include <string>

using namespace std;

constexpr size_t SIZE = 8;
constexpr size_t PATTERN = 7;

const array<string, PATTERN> pattern = {
    "1100000011", "1000000010000000100000001", "1111",
    "1000000110000001", "11000000011",
    "100000001100000001", "110000011"};

string surface;

char match();

int main()
{
    while (true) {
        surface = "";

        for (size_t row = 0; row < SIZE; row++) {
            string buf;
            cin >> buf;

            surface += buf;
        }

        cout << match() << endl;

        cin.ignore(2);
        if (cin.eof()) {
            break;
        }
    }

    return 0;
}

char match()
{
    for (size_t i = 0; i < PATTERN; i++) {
        if (surface.find(pattern.at(i), 0) != string::npos) {
            return static_cast<char>('A' + i);
        }
    }

    cout << "BUG!" << endl;
    return 'X';
}

C++: #include<iostream>
#include<cstdio>

using namespace std;

int A[7][4][4]={
  
  {
    {1,1,0,0},
    {1,1,0,0},
    {0,0,0,0},
    {0,0,0,0},
  },
  
  {
    {1,0,0,0},
    {1,0,0,0},
    {1,0,0,0},
    {1,0,0,0},
  },
  
  {
    {1,1,1,1},
    {0,0,0,0},
    {0,0,0,0},
    {0,0,0,0},
  },
  
  {
    {0,1,0,0},
    {1,1,0,0},
    {1,0,0,0},
    {0,0,0,0},
  },
  
  {
    {1,1,0,0},
    {0,1,1,0},
    {0,0,0,0},
    {0,0,0,0},
  },
  
  {
    {1,0,0,0},
    {1,1,0,0},
    {0,1,0,0},
    {0,0,0,0},
  },
  
  {
    {0,1,1,0},
    {1,1,0,0},
    {0,0,0,0},
    {0,0,0,0},
  },
},
  
  a[12][12];

string s="ABCDEFG";

bool check(int x, int y, int n){
  
  for(int k=0;k<4;k++){
    for(int l=0;l<4;l++){
      int nx=x+k,ny=y+l;
      if(A[n][k][l]==1){
	if(a[nx][ny]!=A[n][k][l]){
	  return false;
	}
	if(nx<0||nx>7||ny<0||ny>7){
	  return false;
	}
      }
    }
  }
  return true;
}


int main(void){

  char ch;

  while(true){

    for(int i=0;i<12;i++)
      for(int j=0;j<12;j++)
	a[i][j]=0;
    
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	if(scanf(" %c",&ch)==EOF)return 0;
	a[i][j]=ch-'0';
      }
    }
    bool fg=true;
    for(int k=0;fg && k<7;k++){
      for(int i=0;fg && i<8;i++){
	for(int j=0;fg && j<8;j++){
	  if(check(i,j,k)){
	    cout << s[k] << endl;
	    fg=false;
	  }
	}
      }
    }
  }

  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct P{ double x, y; };

bool Range(int x, int y)
{ return 0 <= x && x < 8 && 0 <= y && y < 8; }


const int target[7][3][2] = 
{
	{{1, 0}, {0, 1}, {1, 1}},
	{{0, 1}, {0, 2}, {0, 3}}, 
	{{1, 0}, {2, 0}, {3, 0}},
	{{0, 1}, {-1,1}, {-1,2}},
	{{1, 0}, {1, 1}, {2, 1}},
	{{0, 1}, {1, 1}, {1, 2}},
	{{1, 0}, {0, 1}, {-1,1}}
};



char solve(vector<string>& field)
{
	rep(x, 8) rep(y, 8) rep(t, 7)
	{
		if(Range(x, y) && field[y][x] == '1')
		rep(p, 3)
		{
			int nx = x + target[t][p][0], ny = y + target[t][p][1];
			if(!Range(nx, ny) || field[ny][nx] != '1')
				break;
			else if(p == 2)
			{
				return 'A' + t;
			}
		}
	}

	return 'Z';
}



int main()
{
	while(!cin.eof())
	{	
		vector<string> field;

		rep(i, 8)
		{
			string str;
			cin >> str;
			field.push_back(str);
		}


		cout << solve(field) << endl;
	}
}