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(), "")
		for j := 0; j < 8; j++ {
			ret[i][j], _ = strconv.Atoi(row[j])
		}
	}
	return ret
}

func main() {
	for {
		var board [][]int
		var ans string
		if board = scanBoard(); reflect.DeepEqual(board, [][]int{}) {
			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 <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    char tiya[8][8];
    while(cin>>tiya[0][0]){
    vector<pii>gotiusa;
    rep(i,8)rep(j,8){
        if(i==0&&j==0)continue;
        cin>>tiya[i][j];
        if(tiya[i][j]=='1')gotiusa.push_back(pii(i,j));
    }
    int tate=0;
    int yoko=0;
    pii t=pii(-INF,INF),y=pii(-INF,INF);
    rep(i,gotiusa.size()){
        cmax(t.first,gotiusa[i].first);
        cmin(t.second,gotiusa[i].first);
        cmax(y.first,gotiusa[i].second);
        cmin(y.second,gotiusa[i].second);
    }
    tate=t.first-t.second;
    yoko=y.first-y.second;
    if(tate==3) puts("B");
    else if(yoko==3) puts("C");
    else if(yoko==1&&tate==1)puts("A");
    else if(tate==2&&yoko==1){
        int a = 0,b = 0;
        rep(i,gotiusa.size()){
            if(t.first==gotiusa[i].first)a=gotiusa[i].second;
            else if(t.second==gotiusa[i].first)b=gotiusa[i].second;
        }
            (a>b ? puts("D"):puts("F"));
    }
    else if(tate==1&&yoko==2){
        int a = 0,b = 0;
        rep(i,gotiusa.size()){
            if(y.first==gotiusa[i].second)a=gotiusa[i].first;
            else if(y.second==gotiusa[i].second)b=gotiusa[i].first;
        }
            (a>b ? puts("E"):puts("G"));
        }
        cin.ignore();
    }
    return 0;
}

C++: pln[14][14];
main(i,j,c,f){
	while(1){
		for(i=3;i<11;i++){
			for(j=3;j<11;j++)	pln[i][j]=getchar();
			if(getchar()==-1)	exit(0);
		}
		for(i=3;i<11;i++)for(j=3;j<11;j++)pln[i][j]-='0';
		getchar();

		f=1;
		for(i=3;f&&i<11;i++)for(j=3;f&&j<11;j++)
			if(pln[i][j]){
				if     (pln[i+3][j])	c='B';
				else if(pln[i][j+3])	c='C';
				else if(pln[i+2][j-1])	c='D';
				else if(pln[i+1][j+2])	c='E';
				else if(pln[i+2][j+1])	c='F';
				else if(!pln[i+1][j+1])	c='G';
				else	c='A';
				f=0;
			}
		printf("%c\n",c);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 30;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

string s[7][4] =
{
	{
		"1100",
		"1100",
		"0000",
		"0000"
	},
	{
		"1000",
		"1000",
		"1000",
		"1000"
	},
	{
		"1111",
		"0000",
		"0000",
		"0000"
	},
	{
		"0100",
		"1100",
		"1000",
		"0000"
	},
	{
		"1100",
		"0110",
		"0000",
		"0000"
	},
	{
		"1000",
		"1100",
		"0100",
		"0000"
	},
	{
		"0110",
		"1100",
		"0000",
		"0000"
	}
};
string Add = "00000000000";

int main() {
	string str;
	while ( cin >> str ) {
		VS d;
		d.push_back( str + "000" );
		for ( int i = 0; i < 7; i++ ) {
			cin >> str;
			d.push_back( str + "000" );
		}
		d.push_back( Add );
		d.push_back( Add );
		d.push_back( Add );
		bool break_check = false;
		for ( int i = 0; i < 8; i++ ) {
			for ( int j = 0; j < 8; j++ ) {
				for ( int k = 0; k < 7; k++ ) {
					break_check = true;
					for ( int l = i; l < i + 4; l++ ) {
						if ( d[ l ].substr( j, 4 ) != s[ k ][ l - i ] ) {
							break_check = false;
							break;
						}
					}
					if ( break_check ) {
						printf( "%c\n", k + 'A' );
						break;
					}
				}
				if ( break_check ) {
					break;
				}
			}
			if ( break_check ) {
				break;
			}
		}
	}
	return 0;
}