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<iostream>
using namespace std;

#define W 8
#define H 8

int main()
{
	int map[W][H] = {0};
	char a;
	int i, j;
	int flag;
	char form;

	while (1) {
		for (i = 0; i < W; i++)
			for (j = 0; j < H; j++)
				map[i][j] = 0;
		i = 0;
		j = 0;

		flag = 0;
		while (j<H) {
			if (scanf("%1c", &a) == EOF) {
				flag = 1;
				break;
			}
			if (a!='0' && a!='1') continue;
			map[i++][j] = a-'0';
			if (i == W) {
				i = 0;
				j++;
			}
		}
		if (flag) break;

		flag = 0;
		for (i = 0; i < W; i++) {
			for (j = 0; j < H; j++) {
				if (map[i][j]==1) {
					if (j+2<H && map[i][j+2]==1) {
						form = 'B';
					} else if (i+2<W && map[i+2][j]==1) {
						form = 'C';
					} else if (i+2<W && j-1>=0 && map[i+2][j-1]==1) {
						form = 'G';
					} else if (i+1<W && j-1>=0 && map[i+1][j-1]==1) {
						form = 'D';
					} else if (i+1<W && j+2<H && map[i+1][j+2]==1) {
						form = 'F';
					} else if (j+1<H && map[i][j+1]==1) {
						form = 'A';
					} else {
						form = 'E';
					}
					flag = 1;
					break;
				}
			}
			if (flag) break;
		}
		cout<<form<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

int dx[7][4]={{0,0,1,1},{0,0,0,0},{0,1,2,3},{0,0,-1,-1},{0,1,1,2},{0,0,1,1},{0,-1,0,1}};
int dy[7][4]={{0,1,1,0},{0,1,2,3},{0,0,0,0},{0,1,1,2},{0,0,1,1},{0,1,1,2},{0,1,1,0}};
string MAP[8];

int main(){
	while(1){
	for(int i=0; i<8; ++i){
		for(int j=0; j<8; ++j){
			cin >> MAP[i][j];
		}
	}
	for(int i=0; i<8; ++i){
		for(int j=0; j<8; ++j){
			if(MAP[i][j]=='1'){
				for(int k=0; k<7; ++k){
					bool ok=true;
					for(int l=0; l<4; ++l){
						int nx=j+dx[k][l];
						int ny=i+dy[k][l];
						if(0<=nx&&nx<8&&0<=ny&&ny<8&&MAP[ny][nx]!='1'){
							ok=false;
							break;
						}
					}
					if(ok){
						switch(k){
						case 0:
							cout << "A\n";
							return 0;
							break;
						case 1:
							cout << "B\n";
							return 0;
							break;
						case 2:
							cout << "C\n";
							return 0;
							break;
						case 3:
							cout << "D\n";
							return 0;
							break;
						case 4:
							cout << "E\n";
							return 0;
							break;
						case 5:
							cout << "Fn";
							return 0;
							break;
						case 6:
							cout << "G\n";
							return 0;
							break;
						default:
							break;
						}
					}
				}
			}
		}
	}
	}
	return 0;
}

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

int main(){
    char mas[8][8];
    while(1){
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                cin >> mas[i][j];
            }
        }
        if(cin.eof()) break;
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(mas[i][j] == '1'){
                    if(mas[i+1][j]=='1'&&mas[i][j+1]=='1'&&mas[i+1][j+1]=='1') cout << "A" << endl;
                    else if(mas[i+1][j]=='1'&&mas[i+2][j]=='1'&&mas[i+3][j]=='1') cout << "B" << endl;
                    else if(mas[i][j+1]=='1'&&mas[i][j+2]=='1'&&mas[i][j+3]=='1') cout << "C" << endl;
                    else if(mas[i+1][j]=='1'&&mas[i+1][j-1]=='1'&&mas[i+2][j-1]=='1') cout << "D" << endl;
                    else if(mas[i][j+1]=='1'&&mas[i+1][j+1]=='1'&&mas[i+1][j+2]=='1') cout << "E" << endl;
                    else if(mas[i+1][j]=='1'&&mas[i+1][j+1]=='1'&&mas[i+2][j+1]=='1') cout << "F" << endl;
                    else if(mas[i][j+1]=='1'&&mas[i+1][j]=='1'&&mas[i+1][j-1]=='1') cout << "G" << endl;
                }
            }
        }
    }
}

C++: /* problem 36 */

#include<iostream>

using namespace std;

char board[8][9];

int isA(int x,int y){
	if(y==7){
		return 0;
	}
	else if(board[y][x] == '1' && board[y+1][x] == '1' && board[y][x+1]=='1'&&
		board[y+1][x+1] == '1'){
			return 1;
	}
	else{
		return 0;
	}
}

int isB(int x,int y){
	if(y >= 5){
		return 0;
	}
	else if(board[y][x] == '1' && board[y+1][x] == '1' &&
		board[y+2][x] == '1' && board[y+3][x] == '1'){
			return 1;
	}
	else{
		return 0;
	}
}
int isC(int x,int y){
	if(x>=5){
		return 0;
	}
	else if(board[y][x] == '1' && board[y][x+1] == '1' &&
		board[y][x+2] == '1' && board[y][x+3] == '1'){
			return 1;
	}
	else{
		return 0;
	}
}
int isD(int x,int y){
	if(x==0 || y >= 6){
		return 0;
	}
	else if(board[y][x] == '1' && board[y][x+1]=='1' &&
		board[y-1][x+1] == '1' && board[y-1][x+2] == '1'){
			return 1;
	}
	else{
		return 0;
	}
}

int isE(int x,int y){
	if(x>=6 || y>=7){
		return 0;
	}
	else if(board[y][x] == '1' && board[y+1][x] == '1' &&
		board[y+1][x+1] == '1' && board[y+2][x+1] == '1'){
			return 1;
	}
	else {
		return 0;
	}
}
int isF(int x,int y){
	if(x>=7 || y>=6 ){
		return 0;
	}
	else if(board[y][x] == '1' && board[y][x+1] == '1' &&
		board[y+1][x+1] == '1' && board[y+1][x+2] == '1'){
			return 1;
	}
	else{
		return 0;
	}
}

int isG(int x,int y){
	if(x>=6 ||y==0){
		return 0;
	}
	else if(board[y][x] == '1' && board[y+1][x] == '1'&&
		board[y+1][x-1] == '1' && board[y+2][x-1]=='1'){
			return 1;
	}
	else{
		return 0;
	}
}

int main(){


	while(cin>>board[0]){
		for(int i=1;i<8;i++){
			cin>>board[i];
		}

		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(board[j][i] == '1'){
					if(isA(i,j)){
						cout<<"A"<<endl;
					}
					else if(isB(i,j)){
						cout<<"B"<<endl;
					}
					else if(isC(i,j)){
						cout<<"C"<<endl;
					}
					else if(isD(i,j)){
						cout<<"D"<<endl;
					}
					else if(isE(i,j)){
						cout<<"E"<<endl;
					}
					else if(isF(i,j)){
						cout<<"F"<<endl;
					}
					else if(isA(i,j)){
						cout<<"G"<<endl;
					}
				}
			}
			if(!(cin>>board[0])){
				break;
			}
		}
	}
	return 0;
}