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
}

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 <stdio.h>

#define N 8

#define DEBUG 0
#define debug if(DEBUG)

int main(void){
	int fld[N][N];
	int isEOF;
	char buf[N+1];
	int top, btm, lft, rit;
	
	while (1){
		for (int i=0; i<N; i++){
			isEOF = (scanf("%s", buf) == EOF);
			for (int j=0; j<N; j++){
				fld[j][i] = buf[j] - '0';
			}
		}
		if (isEOF) break;
		debug{
			puts("+--------+");
			for (int i=0; i<N; i++){
				printf("|");
				for (int j=0; j<N; j++){
					printf("%c", fld[j][i]?'@':'.');
				}
				printf("|\n");
			}
			puts("+--------+");
		}
		// check boundary
		top = -1;
		for (int i=0; i<N; i++){
			for (int j=0; j<N; j++){
				if (fld[j][i]) top = i;
			}
			if (top != -1) break;
		}
		btm = -1;
		for (int i=N-1; i>=0; i--){
			for (int j=0; j<N; j++){
				if (fld[j][i]) btm = i;
			}
			if (btm != -1) break;
		}
		lft = -1;
		for (int i=0; i<N; i++){
			for (int j=0; j<N; j++){
				if (fld[i][j]) lft = i;
			}
			if (lft != -1) break;
		}
		rit = -1;
		for (int i=N-1; i>=0; i--){
			for (int j=0; j<N; j++){
				if (fld[i][j]) rit = i;
			}
			if (rit != -1) break;
		}
		debug printf("bound: (%d,%d)-(%d,%d)\n", lft, top, rit, btm);
		// check shape ptn
		if (top == btm) puts("C");
		else if (lft == rit) puts("B");
		else if (btm - top == rit - lft == 1) puts("A");
		else if (btm - top > rit - lft) puts(fld[lft][top]?"D":"F");
		else puts(fld[lft][top]?"E":"G");
		
	}
	// 
	return 0;
}

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

using namespace std;

int main()
{
    array<pair<int, int> const, 4> const p[7] ={
        {{{0,0}, {1,0}, {0,1}, {1,1}}},
        {{{0,0}, {0,1}, {0,2}, {0,3}}},
        {{{0,0}, {1,0}, {2,0}, {3,0}}},
        {{{0,0}, {-1,1}, {0,1}, {-1,2}}},
        {{{0,0}, {1,0}, {1,1}, {2,1}}},
        {{{0,0}, {0,1}, {1,1}, {1,2}}},
        {{{0,0}, {1,0}, {-1,1}, {0,1}}},
    };

    string e;
    do {
        bool b[20][20] = {};
        int fx = -1, fy = -1;
        for( int y=4; y<8+4; ++y ) {
            for( int x=4; x<8+4; ++x ) {
                char c;
                cin >> c;
                b[x][y] = c == '1';
                if ( b[x][y] && fx == -1 && fy == -1) {
                    fx = x;
                    fy = y;
                }
            }
        }

        for( int i=0; i<7; ++i ) {
            if ( b[fx+p[i][0].first][fy+p[i][0].second]
                 && b[fx+p[i][1].first][fy+p[i][1].second]
                 && b[fx+p[i][2].first][fy+p[i][2].second]
                 && b[fx+p[i][3].first][fy+p[i][3].second]
                ) {
                cout << static_cast<char>( 'A' + i ) << endl;
                break;
            }
        }

    } while( getline( cin, e ) );
}

C++: #include<iostream>
using namespace std;
char c[8][8];
void input() {
	for (int i = 0; i < 8; i++)
		for (int j = 0; j < 8; j++)
			cin >> c[i][j];
}
int main() {
	while (!cin.eof()){
		input();
		int a, b;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (c[i][j] == '1') {
					a = i;
					b = j;
					goto C;
				}
			}
		}
	C:
		if (c[a][b + 1] == '1') {
			if (c[a + 1][b] == '1') {
				if (c[a + 1][b + 1] == '1')
					cout << 'A';
				else cout << 'G';
			}
			else {
				if (c[a + 1][b + 1] == '1')
					cout << 'E';
				else cout << 'C';
			}
		}
		else if (c[a + 1][b + 1] == '1')
			cout << 'F';
		else if (c[a + 1][b - 1] == '1')
			cout << 'D';
		else cout << 'B';
		cout << endl;
	}
	return 0;
}

C++: #include <cstdio>
using namespace std;

int main(){
	char ch[8][8];
	bool judged;
	
	while((scanf("%s", ch[0])) != EOF){
		for(int i = 1; i < 8; i++){
				scanf("%s", ch[i]);
		}
		
		judged = false;
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				if(ch[i][j] == '1'){
					//A
					if(i + 1 < 8 && ch[i + 1][j] == '1' &&
					 j + 1 < 8 && ch[i][j + 1] == '1' &&
					 ch[i + 1][j + 1] == '1'){
						printf("A\n");
						judged = true;
						break;
					}
					//B
					if(i + 3 < 8 && ch[i + 1][j] == '1' &&
					 ch[i + 2][j] == '1' && ch[i + 3][j] == '1'){
						printf("B\n");
						judged = true;
						break;
					}
					//C
					if(j + 3 < 8 && ch[i][j + 1] == '1' &&
					 ch[i][j + 2] == '1' && ch[i][j + 3] == '1'){
						printf("C\n");
						judged = true;
						break;
					}
					//D
					if(i + 2 < 8 && j - 1 >= 0 &&
					 ch[i + 1][j - 1] == '1' && ch[i + 1][j] == '1' &&
					 ch[i + 2][j - 1] == '1'){
						printf("D\n");
						judged = true;
						break;
					}
					//E
					if(i + 1 < 8 && j + 2 < 8 &&
					 ch[i][j + 1] == '1' && ch[i + 1][j + 1] == '1' &&
					 ch[i + 1][j + 2] == '1'){
						printf("E\n");
						judged = true;
						break;
					}
					//F
					if(i + 1 < 8 && j + 2 < 8 &&
					 ch[i + 1][j] == '1' && ch[i + 1][j + 1] == '1' &&
					 ch[i + 2][j + 1] == '1'){
						printf("F\n");
						judged = true;
						break;
					}
					//G
					if(i + 1 < 8 && j + 1 < 8 && j - 1 >= 0 &&
					 ch[i + 1][j] == '1' && ch[i][j + 1] == '1' &&
					 ch[i + 1][j - 1] == '1'){
						printf("G\n");
						judged = true;
						break;
					}
				}
			}
			
			if(judged) break;
		}
	}
	
	return 0;
}