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(), "")
		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<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
char ta[12][12];

bool ok(int y,int x){
	if(y<0||x<0||y>7||x>7)return 0;
	if(ta[y][x]=='1')return 1;
	return 0;
}
int main(){

while(cin>>ta[0][0]){
	int y,x;
	bool f=1;
	for(int i=0;i<8;i++){
		for(int j=(i==0);j<8;j++){
			char now;
			cin>>now;
			if(now=='1'&&f){y=i,x=j;f=0;}
			ta[i][j]=now;
		}
	}
	//for(int i=0;i<8;i++){for(int j=0;j<8;j++){cout<<ta[i][j];}cout<<endl;}
	if( ok(y,x+1)&ok(y+1,x)&&ok(y+1,x+1) )cout<<"A";
	
	else if( ok(y+1,x)&&ok(y+2,x)&&ok(y+3,x) )cout<<"B";
	
	else if( ok(y,x+1)&&ok(y,x+2)&&ok(y,x+3) )cout<<"C";
	
	else if( ok(y,x+1)&ok(y+1,x+1)&&ok(y+1,x+2) )cout<<"E";
	
	else if( ok(y+1,x)&&ok(y+1,x+1) &&ok(y+2,x+1))cout<<"F";
	
	else if( ok(y,x+1)&&ok(y+1,x)&&ok(y+1,x-1) )cout<<"G";
	
	else if( ok(y+2,x-1)&&ok(y+1,x-1)&&ok(y+1,x))cout<<"D";

	cout<<endl;
		for(int i=0;i<8;i++)for(int j=0;j<8;j++)ta[i][j]='0';
}
	
	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    char m[15][15] = {'0'};
    bool check = true;
    while(check){
        range(i,4,12){
            if(cin >> m[i]){
                ;
            }else{
                check = false;
            }
        }
        range(i,4,12){
            range(j,0,8){
                if(m[i][j] == '1' && m[i+1][j] == '1' && m[i][j+1] == '1' && m[i+1][j+1] == '1'){
                     cout << 'A' << endl;
                      break;
                }
                if(m[i][j] == '1' && m[i+1][j] == '1' && m[i+2][j] == '1' && m[i+3][j] == '1'){
                     cout << 'B' << endl;
                      break;
                }
                if(m[i][j] == '1' && m[i][j+1] == '1' && m[i][j+2] == '1' && m[i][j+3] == '1'){
                     cout << 'C' << endl;
                      break;
                }
                if(m[i][j] == '1' && m[i+1][j] == '1' && m[i-1][j+1] == '1' && m[i-2][j+1] == '1'){
                     cout << 'D' << endl;
                      break;
                }
                if(m[i][j] == '1' && m[i][j+1] == '1' && m[i+1][j+1] == '1' && m[i+1][j+2] == '1'){
                     cout << 'E' << endl;
                      break;
                }
                if(m[i][j] == '1' && m[i+1][j] == '1' && m[i+1][j+1] == '1' && m[i+2][j+1] == '1'){
                     cout << 'F' << endl;
                      break;
                }
                if(m[i][j] == '1' && m[i][j+1] == '1' && m[i+1][j-1] == '1' && m[i+1][j] == '1'){
                     cout << 'G' << endl;
                      break;
                }
            }
        }
    }
}

C++: #include<stdio.h>

int main(){
char a[8][8];
int ans = 0;
while(1){
for(int i = 0; i < 8; i++){
if(scanf("%s",&a[i]) == EOF){
return 0;
}
}

for(int i = 0; i < 8; i++){
for(int j = 0; j < 8; j++){
if(a[i][j] == 1){
if(i < 7 && j < 7){
if(a[i+1][j] == 1 && a[i][j+1] == 1 && a[i+1][j+1] == 1){
printf("A\n");
}
}
if(i < 5){
if(a[i+1][j] == 1 && a[i+2][j] == 1 && a[i+3][j] == 1){
printf("B\n");
}
}
if(j < 5){
if(a[i][j+1] == 1 && a[i][j+2] == 1 && a[i][j+3] == 1){
printf("C\n");
}
}
if(i < 6 && j < 5){
if(a[i][j+1] == 1 && a[i+1][j+1] == 1 && a[i+1][j+2] == 1){
printf("E\n");
}
}
if(i < 5 && j < 6){
if(a[i+1][j] == 1 && a[i+1][j+1] == 1 && a[i+2][j+1] == 1){
printf("F\n");
}
}
if(j > 0 && i < 6){
if(a[i+1][j] == 1 && a[i+1][j-1] == 1 && a[i+2][j-1] == 1){
printf("D\n");
}
}
if(j > 0 && j < 7 && i < 7){
if(a[i+1][j] == 1 && a[i][j+1] == 1 && a[i+1][j-1] == 1){
printf("G\n");
}
}
}
}
}
}
}
return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define X first
#define Y second
#define WIDTH 8
#define HEIGHT 8

using namespace std;

vector<string> init(){
	vector<string> map;
	for(int i = 0; i < HEIGHT; i++){
		string tmp;
		getline(cin,tmp);
		map.push_back(tmp);
	}
	return map;
}

void countNum(vector<string> map, int *count){
	int counter = -1;
	
	for(int i = 0; i < HEIGHT; i++){
		for(int j = 0; j < WIDTH ; j++){
			if(map[i][j] == '1'){
				counter++;
				if(counter == 3) return;
			}
			else{
				if(counter >= 0) count[counter]++;
			}
		}
	}

	return;
}


char decideChar(int *count){
	if(count[0] == 0 && count[1] == 6 && count[2] == 0){
		return 'A';
	}
	else if(count[0] == 7 && count[1] == 7 && count[2] == 7){
		return 'B';
	}
	else if(count[0] == 0 && count[1] == 0 && count[2] == 0){
		return 'C';
	}
	else if(count[0] == 6 && count[1] == 0 && count[2] == 6){
		return 'D';
	}
	else if(count[0] == 0 && count[1] == 7 && count[2] == 0){
		return 'E';
	}
	else if(count[0] == 7 && count[1] == 0 && count[2] == 7){
		return 'F';
	}
	else if(count[0] == 0 && count[1] == 5 && count[2] == 0){
		return 'G';
	}
}



int main(){
	
	while(1){
		if(cin.eof()) break;
		vector<string> map = init();
		int count[] = {0, 0, 0};
		countNum(map, count);
		cout << decideChar(count) << endl;
		//入力で一行改行が入ってしまうのでそれ対策
		string tmp;
		getline(cin, tmp);
	}
	return 0;
}