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 <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(){
    string temp;
    while(cin>>temp){
        vector<string>tiya;
        vector<pii>gotiusa;
        tiya.push_back(temp);
    rep(i,7){
        string temp;
        cin>>temp;
        tiya.push_back(temp);
    }
    rep(i,8)rep(j,tiya[i].size())
        if(tiya[i][j]=='1')gotiusa.push_back(pii(7-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("G"):puts("E"));
        }
    }
    return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

/*
A 2*2 B 1*4 C 4*1 D 01 E 110 F 10 G 011
                    11   011   11   110
                    10         01
*/

int main() {
	while (true) {
		string in[4];
		string tmp;
		int j=0;
		for (int i=0; i<8; i++) {
			cin >> tmp;
			if (tmp != "00000000") {
				in[j] = tmp;
				j++;
			}
		}
		if (j == 4) {
			cout << "B" << endl;
		} else if (j == 1) {
			cout << "C" << endl;
		} else if (j == 2) {
			if (in[0] == in[1]) {
				cout << "A" << endl;
			} else if (in[0] > in[1]) {
				cout << "E" << endl;
			} else {
				cout << "G" << endl;
			}
		} else {
			if (in[0] > in[1]) {
				cout << "F" << endl;
			} else {
				cout << "D" << endl;
			}
		}
		scanf("\n");
	}
	return 0;
}

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

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	bool cell[8][8] = {false};
	int ans = 0;
	REP(i, 8){
		string s;
		cin >> s;
		REP(j, 8){
			if (s[j] == '1')
				cell[i][j] = true;
		}
	}

	REP(i, 8){
		REP(j, 8){
			if (cell[i][j]){
				REP(k, 3)
					REP(l, 3)
					if (i + (k - 1) >= 0 && i + (k - 1) < 8 && j + (l - 1) >= 0 && j + (l - 1) < 8 && cell[i + (k - 1)][j + (l - 1)])
						ans += 1 << (8-(k * 3 + l));
				i = 8;
				j = 8;
			}
		}
	}
	switch (ans){
	case 27:
		cout << 'A' << endl;
		break;
	case 18:
		cout << 'B' << endl;
		break;
	case 24:
		cout << 'C' << endl;
		break;
	case 22:
		cout << 'D' << endl;
		break;
	case 25:
		cout << 'E' << endl;
		break;
	case 19:
		cout << 'F' << endl;
		break;
	case 30:
		cout << 'G' << endl;
		break;
	}

}