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 <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++;
			}
		}
		scanf("\n");
		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;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
struct Rect
{
	Rect(){
		minX = minY = 10000;
		maxX = maxY = -10000;
	}
	void add(int i, int j){
		if (minX > i) minX = i;
		if (minY > j) minY = j;
		if (maxX < i) maxX = i;
		if (maxY < j) maxY = j;
	}
	int getWidth() {
		return (maxY - minY + 1);
	}
	int getHeight() {
		return (maxX - minX + 1);
	}
	int minX;
	int minY;
	int maxX;
	int maxY;
};
int main()
{
	char c;
	int A[8][8] = {};
	while (true){
		Rect r;
		for (int i = 0; i < 8; ++i){
			for (int j = 0; j < 8; ++j){
				cin.get(c);
				if (c == '1') A[i][j] = 1;
				else A[i][j] = 0;
				if (1 == A[i][j])
					r.add(i, j);
			}
			cin.get(c);
		}
		int w = r.getWidth();
		int h = r.getHeight();
		if (1 == w) cout << "B\n";
		else if (1 == h) cout << "C\n";
		else if (2 == w && 2 == h) cout << "A\n";
		else if (2 == w && 3 == h){
			if (A[r.minX][r.minY] == 1) cout << "F\n";
			else cout << "D\n";
		}
		else if (3 == w && 2 == h){
			if (A[r.minX][r.minY] == 1) cout << "E\n";
			else cout << "G\n";
		}
		if (!cin.get(c))
			break;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stack>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

char mass[16][16];

char solve(int i, int j)
{
    if (mass[i][j] == '1' && mass[i][j+1] == '1' && mass[i+1][j] == '1' && mass[i+1][j+1] == '1') {
        return 'A';
    }
    else if (mass[i][j] == '1' && mass[i+1][j] == '1' && mass[i+2][j] == '1' && mass[i+3][j] == '1') {
        return 'B';
    }
    else if (mass[i][j] == '1' && mass[i][j+1] == '1' && mass[i][j+2] == '1' && mass[i][j+3] == '1') {
        return 'C';
    }
    else if (mass[i][j] == '1' && mass[i+1][j] == '1' && mass[i+1][j-1] == '1' && mass[i+2][j-1] == '1') {
        return 'D';
    }
    else if (mass[i][j] == '1' && mass[i][j+1] == '1' && mass[i+1][j+1] == '1' && mass[i+1][j+2] == '1') {
        return 'E';
    }
    else if (mass[i][j] == '1' && mass[i+1][j] == '1' && mass[i+1][j+1] == '1' && mass[i+2][j+1] == '1') {
        return 'F';
    }
    else if (mass[i][j] == '1' && mass[i][j+1] == '1' && mass[i+1][j] == '1' && mass[i+1][j-1] == '1') {
        return 'G';
    }
    
    return 0;
}

int main(void)
{
    char c;
    bool f;
    
    while (!cin.eof()) {
        f = false;
        
        rep(i, 16) {
            rep(j, 16) {
                mass[i][j] = '0';
            }
        }

        rep(i, 8) {
            cin >> mass[i];
        }
        
        rep(i, 8) {
            rep(j, 8) {
                if (mass[i][j] == '1' && f == false) {
                    c = solve(i, j);
                    cout << c << endl;
                    f = true;
                }
            }
        }
    }
    
    return 0;
}