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 <stdio.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const char dat[7][4][5] = {
    { "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" },
};

char f[16][16];

bool match(int k, int x, int y) {
    rep (i, 4) rep (j, 4) if (f[x+i][y+j] != dat[k][i][j]) return false;
    return true;
}

int solve() {
    rep (k, 7) rep (i, 8) rep (j, 8) if (match(k, i, j)) return k;
    return -1;
}

int main() {
    memset(f, '0', sizeof(f));
    while (scanf(" %c", f[0]) != EOF) {
        rep (i, 8) rep (j, 8) if (i || j) scanf(" %c", f[i]+j);
        printf("%c\n", (char)('A'+solve()));
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
bool check(int (&field)[8][8],int x,int y){
	if(x<0 || x>=8 || y<0 || y>=8 || (field[y][x] == 0)){
		return false;
	}
	return true;
}

int main(){
	int inptf[8][8] = {0}, i, j, x, y;
	string str;
	char btype;
	while(true){
		i=0;
		while(cin>>str){
			for(j=0;j<8;j++){
				inptf[i][j] = str[j] - '0';
			}
			i++;
			if(i==8) break;
		}
		if(i<8) break;
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				if(inptf[i][j] != 0){
					y = i;
					x = j;
					i=j=8;
				}
			}
		}
		if(check(inptf , x, y) &&	//[][] A
		   check(inptf , x, y+1) &&	//[][]
		   check(inptf , x+1, y) &&	
		   check(inptf , x+1, y+1))	
			btype='A';
			
		if(check(inptf , x, y) &&	//[] B
		   check(inptf , x, y+1) &&	//[]
		   check(inptf , x, y+2) &&	//[]
		   check(inptf , x, y+3))	//[]
			btype='B';
		if(check(inptf , x, y) &&	//[][][][] C
		   check(inptf , x+1, y) &&	
		   check(inptf , x+2, y) &&	
		   check(inptf , x+3, y))	
			btype='C';
		if(check(inptf , x, y) &&	//  [] D
		   check(inptf , x, y+1) &&	//[][]
		   check(inptf , x-1, y+1) &&	//[]
		   check(inptf , x-1, y+2) )	
			btype='D';
		if(check(inptf , x, y) &&	//[][] E
		   check(inptf , x+1, y) &&	//  [][]
		   check(inptf , x+1, y+1) &&	
		   check(inptf , x+2, y+1))	
			btype='E';
		if(check(inptf , x, y) &&	//[]   F
		   check(inptf , x, y+1) &&	//[][]
		   check(inptf , x+1, y+1) &&	//  []
		   check(inptf , x+1, y+2))	
			btype='F';
		if(check(inptf , x, y) &&	//  [][]G
		   check(inptf , x+1, y) &&	//[][]
		   check(inptf , x, y+1) &&
		   check(inptf , x-1, y+1))	
			btype='G';
		cout<<btype<<endl;
	}
}

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

struct ca {
	int x;
	int y;
};

int main() {
	ca l[4];
	char c;
	while (!cin == EOF) {
		int a = 0;
		for (int i = 0; i < 8; i++) {
			for (int j = 1; j < 8; j++) {
				cin >> c;
				if (c == '1')
				{
					l[a].x = i;
					l[a].y = j;
					a++;
				}
			}
		}
		int x = l[0].x;
		int y = l[0].y;
		if (l[1].x == x&&l[1].y == y + 1) {
			//[l0][l1]
			//ACEG
			if (l[3].x == x + 1 && l[3].y == y + 1)
				cout << 'A';
			else if (l[3].y == y + 3)
				cout << 'C';
			else if (l[3].x == x + 1 && l[3].y == y + 2)
				cout << 'E';
			else cout << 'G';
		}
		else if (l[1].x == x + 1 && l[1].y == y) {
			/*[l0]
			  [l1]*/
			  //BF
			if (l[3].x == x + 3 && l[3].y == y)
				cout << 'B';
			else cout << 'F';
		}
		else cout << 'D';
		cout << endl;
	}
	return 0;
}

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

using namespace std;

char map[8][9];

char solve() {
	for (int i=0; i<8; ++i) {
		for (int j=0; j<8; ++j) {
			if (map[i][j] == '1') {
				if (i<7 && j<7 && map[i][j+1]=='1' && map[i+1][j]=='1' && map[i+1][j+1]=='1') return 'A';
				if (i<5 && map[i+1][j]=='1' && map[i+2][j]=='1' && map[i+3][j]=='1') return 'B';
				if (j<5 && map[i][j+1]=='1' && map[i][j+2]=='1' && map[i][j+3]=='1') return 'C';
				if (i<6 && j>0 && map[i+1][j]=='1' && map[i+1][j-1]=='1' && map[i+2][j-1]=='1') return 'D';
				if (i<7 && j<6 && map[i][j+1]=='1' && map[i+1][j+1]=='1' && map[i+1][j+2]=='1') return 'E';
				if (i<6 && j<7 && map[i+1][j]=='1' && map[i+1][j+1]=='1' && map[i+2][j+1]=='1') return 'F';
				if (i<7 && j<7 && j>0 && map[i][j+1]=='1' && map[i+1][j]=='1' && map[i+1][j-1]=='1') return 'G';
			}
		}
	}
}

int main() {
	while (scanf("%s", map[0]) != EOF) {
		for (int i=1; i<8; ++i) scanf ("%s", map[i]);
		char ans = solve();
		printf ("%c\n", ans);
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int x[13][13]; char a;
int main() {
	while (cin >> a) {
		memset(x, 0, sizeof(x));
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				if (i + j > 2) {
					cin >> a; if (a == '0') { x[i][j] = 0; }
					else { x[i][j] = 1; }
				}
			}
		}
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				if (x[i][j] == 1) {
					if (x[i + 1][j] == 1 && x[i][j + 1] == 1 && x[i + 1][j + 1] == 1) {
						cout << 'A' << endl; goto Exit;
					}
					if (x[i + 1][j] == 1 && x[i + 2][j] == 1 && x[i + 3][j] == 1) {
						cout << 'B' << endl; goto Exit;
					}
					if (x[i][j + 1] == 1 && x[i][j + 2] == 1 && x[i][j + 3] == 1) {
						cout << 'C' << endl; goto Exit;
					}
					if (x[i + 1][j - 1] == 1 && x[i + 1][j] == 1 && x[i + 2][j - 1] == 1) {
						cout << 'D' << endl; goto Exit;
					}
					if (x[i][j + 1] == 1 && x[i + 1][j + 1] == 1 && x[i + 1][j + 2] == 1) {
						cout << 'E' << endl; goto Exit;
					}
					if (x[i + 1][j] == 1 && x[i + 1][j + 1] == 1 && x[i + 2][j + 1] == 1) {
						cout << 'F' << endl; goto Exit;
					}
					if (x[i][j + 1] == 1 && x[i + 1][j - 1] == 1 && x[i + 1][j] == 1) {
						cout << 'G' << endl; goto Exit;
					}
				}
			}
		}
	Exit:;
	}
}