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 <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::vector<std::string> image;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	while(std::getline(ifs, buf)){
#else
	while(std::getline(std::cin, buf)){
#endif
		image.clear();
		image.push_back(buf);
		for(int i = 0; i < 7; i++){
#if INPUT_FROM_FILE
			std::getline(ifs, buf);
#else
			std::getline(std::cin, buf);
#endif
			
			image.push_back(buf);
		}
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif

		int w = 8;
		int h = 8;
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++){
				if(image[y][x] == '1'){
					//A
					if(x < w - 1 && y < h - 1 && image[y][x + 1] == '1' && image[y + 1][x] == '1' && image[y + 1][x + 1] == '1'){
						std::cout << "A" << std::endl;
						y = h;
						break;
					}
					//B
					else if(y < h - 3 && image[y + 1][x] == '1' && image[y + 2][x] == '1' && image[y + 3][x] == '1'){
						std::cout << "B" << std::endl;
						y = h;
						break;
					}
					//C
					else if(x < w - 3 && image[y][x + 1] == '1' && image[y][x + 2] == '1' && image[y][x + 3] == '1'){
						std::cout << "C" << std::endl;
						y = h;
						break;
					}
					//D
					else if(x >= 1 && y < h - 2 && image[y + 1][x] == '1' && image[y + 1][x - 1] == '1' && image[y + 2][x - 1] == '1'){
						std::cout << "D" << std::endl;
						y = h;
						break;
					}
					//E
					else if(x < w - 2 && y < h - 1 && image[y][x + 1] == '1' && image[y + 1][x + 1] == '1' && image[y + 1][x + 2] == '1'){
						std::cout << "E" << std::endl;
						y = h;
						break;
					}
					//F
					else if(x < w - 1 && y < h - 2 && image[y + 1][x] == '1' && image[y + 1][x + 1] == '1' && image[y + 2][x + 1] == '1'){
						std::cout << "F" << std::endl;
						y = h;
						break;
					}
					else{
						std::cout << "G" << std::endl;
						y = h;
						break;
					}
				}
			}
		}
	}

	return 0;
}

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

#define MAX 8

using namespace std;
bool field[9][9];
int x, y;

char solve(){
  if(x+1 < MAX && y+1 < MAX && field[y][x+1] && field[y+1][x] && field[y+1][x+1]) return 'A';
  else if(y+3 < MAX && field[y+1][x] && field[y+2][x] && field[y+3][x]) return 'B';
  else if(x+3 < MAX && field[y][x+1] && field[y][x+2] && field[y][x+3]) return 'C';
  else if(x-1 >= 0 && y+2 < MAX &&field[y+1][x] && field[y+1][x-1] && field[y+2][x-1]) return 'D';
  else if(x+2 < MAX && y+1 < MAX &&field[y][x+1] && field[y+1][x+1] && field[y+1][x+2]) return 'E';
  else if(x+1 < MAX && y+2 < MAX &&field[y+1][x] && field[y+1][x+1] && field[y+2][x+1]) return 'F';
  else if(x-1 >= 0 && y+1 < MAX &&field[y][x+1] && field[y+1][x-1] && field[y+1][x]) return 'G';
}


int main(){
  string tmp[8];
  
  while(cin >> tmp[0] >> tmp[1] >> tmp[2] >> tmp[3] >> tmp[4] >> tmp[5]
	>> tmp[6] >> tmp[7]){
    bool flag = 0;
    
    for(int i = 0 ; i < 8 ; i++){
      for(int j = 0 ; j < 8 ; j++){
	field[i][j] = tmp[i][j] - '0';
      }
    }
    
    for(y = 0 ; y < 8 ; y++){
      for(x = 0 ; x < 8 ; x++){
	if(field[y][x] && !flag){
	  cout << solve();
	  flag = 1;
	}
      }
    }
    cout << endl;
  }
  return 0;
}