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)
		fmt.Scanln()
	}
}

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

int main(){
	int mass[8][8];
	
	BEGIN:
	while(scanf("%d%d%d%d%d%d%d%d",mass[0],mass[0]+1,mass[0]+2,mass[0]+3,mass[0]+4
	mass[0]+5,mass[0]+6,mass[0]+7)!=EOF)
	{
		for(int i=1;i<8;i++){
			scanf("%d%d%d%d%d%d%d%d",mass[i],mass[i]+1,mass[i]+2,mass[i]+3,mass[i]+4
				mass[i]+5,mass[i]+6,mass[i]+7);
		}
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(mass[i][j]){
					if(j==7){
						if(mass[i+1][j]){
							cout<<(mass[i+1][j-1]?"D\n":"B\n");
						}
					}else if(j==0){
						if(mass[i][j+1]){
							if(mass[i+1][j]) cout<<"A\n";
							else if(mass[i][j+2]) cout<<"C\n";
							else cout<<"E\n";
						}
						else cout<(mass[i+1][j+1]?"F\n":"B\n");
					}else{
						if(mass[i][j+2]) cout<<"C\n";
						else if(mass[i][j+1]){
							if(mass[i+1][j]){
								cout<<(mass[i+1][j+1]?"A\n":"G\n");
							}
							else cout<<"E\n";
						}
						else if(mass[i+2][j]) cout<<"B\n";
						else cout<<(mass[i+1][j+1]?"F\n":"D\n");
					}
					goto BEGIN;
				}
			}
		}
	}
}

C++: #include <iostream>

#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

int main() {
	char a, c;
	int map[10][10];

	while(cin >> c) {
		if(c == '0' || c== '1') {
			rep(i,10)rep(j,10)
				map[i][j] = 0;

			rep(i,8)rep(j,8) {
				if(!(i + j == 0)) cin >> c;
				map[i][j] = (int)(c - '0');
			}

			rep(i,8)rep(j,8) {
				if(map[i][j]) {
					if(map[i][j+2])   a = 'C';
					if(map[i+2][j])   a = 'B';
					if(map[i+1][j+1]) a = 'A';
					if(map[i+1][j-1]) a = 'G';
					if(map[i+1][j+2]) a = 'E';
					if(map[i+2][j+1]) a = 'F';
					if(map[i+2][j-1]) a = 'D';
					break;
				}
			}

			cout << a << endl;
		}
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    char fg[8][8];

    while (cin >> fg[0][0]) {
        for (int i = 0; i < 8; i++)
            for (int j = 0; j < 8; j++) {
                if (!i && !j)
                    continue;
                cin >> fg[i][j];
            }

        int x, y;
        bool flag = false;
        for (y = 0; y < 8; y++) {
            for (x = 0; x < 8; x++)
                if (fg[y][x] == '1') {
                    flag = true;
                    break;
                }
            if (flag)
                break;
        }

        if (fg[y][x + 1] == '1') {
            if (fg[y][x + 2] == '1') 
                cout << "C\n";
            else if (fg[y + 1][x + 2] == '1') 
                cout << "E\n";
            else if (fg[y + 1][x - 1] == '1') 
                cout << "G\n";
            else 
                cout << "A\n";
        }
        else if (fg[y + 2][x] == '1')
            cout << "B\n";
        else if (fg[y + 1][x - 1] == '1')
            cout << "D\n";
        else 
            cout << "F\n";
    }

    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
string str[10]; 
void ans(int i,int k){
	if(str[i][k+1] == '1' && str[i+1][k+1] == '1'&& str[i+1][k] == '1' ){
		cout << "A" << endl;  
		} else if(str[i+1][k] == '1' && str[i+2][k] == '1'&& str[i+3][k] == '1' ){
		cout << "B" << endl; 
		} else if(str[i][k+1] == '1' && str[i][k+2] == '1'&& str[i][k+3] == '1' ){
		cout << "C" << endl;  
		} else if(str[i+1][k] == '1' && str[i+1][k-1] == '1'&& str[i+2][k-1] == '1' ){
		cout << "D" << endl; 
		} else if(str[i][k+1] == '1' && str[i+1][k+1] == '1'&& str[i+1][k+2] == '1' ){
		cout << "E" << endl; 
		} else if(str[i+1][k] == '1' && str[i+1][k+1] == '1'&& str[i+2][k+1] == '1' ){
		cout << "F" << endl;  
		} else if(str[i][k+1] == '1' && str[i+1][k] == '1'&& str[i+1][k-1] == '1' ){
		cout << "G" << endl; 
		}

}

int main(){
	
	while(1){
	
	for(int i =0;i<10;i++)
	if(!(cin>>str[i]))return 0;
	
	
	for(int i=0;i<64;i++)
	if(str[i/8][i%8] == '1')
	ans(i/8,i%8);
	break;

	
	}
	
}

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

char charField[15][15];

int main(){
	while(cin >> charField[0][0]){

		for(int i=0; i < 15; i++){
			for(int j=0; j < 15; j++){
				charField[i][j] = '0';
			}
		}

		for(int i=0; i < 8; i++){
			for(int j=0; j < 8; j++){
				if(i==0 && j == 0)continue;
				cin >> charField[j][i];
			}
		}

		for(int i=0; i < 8; i++){
			for(int j=0; j < 8; j++){
				cout << charField[i][j];
			}
			cout << endl;
		}

		for(int i=0; i < 8; i++){
			for(int j=0; j < 8; j++){
				if(charField[i][j] == '1' && charField[i+1][j] == '1' && charField[i][j+1] && charField[i+1][j+1] == '1') cout << "A" << endl;
				else if(charField[i][j] == '1' && charField[i][j+1] == '1' && charField[i][j+2] == '1' && charField[i][j+3] == '1') cout << "B" << endl;
				else if(charField[i][j] == '1' && charField[i+1][j] == '1' && charField[i+2][j] == '1' && charField[i+3][j] == '1') cout << "C" << endl;
				else if(charField[i+1][j] == '1' && charField[i+1][j+1] == '1' && charField[i][j+1] == '1' && charField[i][j+2] == '1') cout << "D" << endl;
			 	else if(charField[i][j] == '1' && charField[i+1][j] == '1' && charField[i+1][j+1] == '1' && charField[i+2][j+1] == '1') cout << "E" << endl;
				else if(charField[i][j] == '1' && charField[i+1][j] == '1' && charField[i+1][j+1] == '1' && charField[i+1][j+2] == '1') cout << "F" << endl;
				else if(charField[i+1][j] == '1' && charField[i+1][j+1] == '1' && charField[i][j+1] == '1' && charField[i][j+2] == '1') cout << "G" << endl;
			}

		}
	}
}