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++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	VS s(10);
	while (cin >> s[0]) {
		s[0] += "00000";
		FOR(i, 1, 8) { cin >> s[i]; s[i] += "00000"; }
		s[8] = string(15, '0');
		s[9] = string(15, '0');

		int x = -1, y = -1;
		rep(i, 8)rep(j, 8) {
			if (x == -1 && y == -1 && s[i][j] == '1') { x = j; y = i; break; }
		}

		bool f2 = s[y + 1][x] == '1';
		bool f1 = s[y][x + 1] == '1';
		bool f3 = s[y + 1][x + 1] == '1';

		char ans = '#';
		if (f1 && f2) {//A G
			ans = f3 ? 'A' : 'G';
		}
		else if (f1 && !f2) {//C E
			ans = f3 ? 'E' : 'C';
		}
		else if (!f1 && f2) {//B D F
			if (f3)ans = 'F';
			else ans = s[y + 2][x] == '1' ? 'B' : 'D';
		}
		Cout(ans);
	}
}

C++: #include <iostream>

using namespace std;

const bool O = true, X = false;

const bool A[4] = {
    O, O,
    O, O
};

const bool B[4] = {
    O,
    O,
    O,
    O
};

const bool C[4] = {
    O, O, O, O
};

const bool D[6] = {
    X, O,
    O, O,
    O, X
};

const bool E[6] = {
    O, O, X,
    X, O, O
};

const bool F[6] = {
    O, X,
    O, O,
    X, O
};

const bool G[6] = {
    X, O, O,
    O, O, X
};

bool matched(const bool map[8][8], const bool* pattern, const int h, const int w) {
    for (int i = 0; i < 8 - h; i++) {
        for (int j = 0; j < 8 - w; j++) {
            bool unmatched = false;
            for (int a = 0; a < h; a++) {
                for (int b = 0; b < w; b++) {
                    if (map[i + a][j + b] != pattern[a * w + b]) {
                        unmatched = true;
                        break;
                    }
                }
            }
            if (!unmatched) return true;
        }
    }
    return false;
}

int main(void) {
    bool map[8][8];
    char c;
    while (true) {
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                cin >> c;
                map[i][j] = (c == '1');
            }
        }
        if (cin.eof()) break;
        cin.ignore();
        char p;
        if      (matched(map, A, 2, 2)) cout << "A" << endl;
        else if (matched(map, B, 4, 1)) cout << "B" << endl;
        else if (matched(map, C, 1, 4)) cout << "C" << endl;
        else if (matched(map, D, 3, 2)) cout << "D" << endl;
        else if (matched(map, E, 2, 3)) cout << "E" << endl;
        else if (matched(map, F, 3, 2)) cout << "F" << endl;
        else if (matched(map, G, 2, 3)) cout << "G" << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int field[8][8],f = 0;
	for(;;){
		for(int i=0; i<8; i++){
			for(int l=0; l<8; l++){
				if(scanf("%1d",&field[l][i]) == EOF){f = 1;break;}
			}
			if(f == 1){break;}
		}
		if(f == 1){break;}
		for(int i=0; i<8; i++){
			for(int l=0; l<8; l++){
				if(field[l][i]){
					if(field[l][i+1] && field[l+1][i] && field[l+1][i+1]){cout<<"A"<<endl;break;}
					else if(field[l][i+1] && field[l][i+2] && field[l][i+3]){cout<<"B"<<endl;break;}
					else if(field[l+1][i] && field[l+2][i] && field[l+3][i]){cout<<"C"<<endl;break;}
					else if(field[l][i+1] && field[l-1][i+1] && field[l-1][i+2]){cout<<"D"<<endl;break;}
					else if(field[l+1][i] && field[l+1][i+1] && field[l+2][i+1]){cout<<"E"<<endl;break;}
					else if(field[l][i+1] && field[l+1][i+1] && field[l+1][i+2]){cout<<"F"<<endl;break;}
					else if(field[l+1][i] && field[l][i+1] && field[l-1][i+1]){cout<<"G"<<endl;break;}
				}
			}
		}
	}
	return 0;
}