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 <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

#define LIM 1000010

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int dist_fl[] = {9, 24, 3, 15, 10, 17, 8};
vector<string> surf(8);

char solve(){

	int cnt = 0, dist = 0;
	
	for(int i=0; i < 8; ++i){
		for(int j=0; j<8; ++j){
			
			if(cnt!=0)
				dist++;
			
			if(surf[i][j]=='1')
				cnt++;
			
			if(cnt==4){
				for(int k=0; k<7; ++k){
					if(dist_fl[k]==dist)
						return (char)('A'+k);
				}
			}
		}
	}
}

int main(){
		
	while(cin>>surf[0]>>surf[1]>>surf[2]>>surf[3]
				>>surf[4]>>surf[5]>>surf[6]>>surf[7], !cin.eof()){
		
		cin.ignore();
		cout << solve() << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>

int main(void) {
  char s[8][10];
  int i, j, k, l;
  int dx[7][3] = {
    {1, 1, 0},
    {0, 0, 0},
    {1, 2, 3},
    {0, -1, -1},
    {1, 1, 2},
    {0, 1, 1},
    {1, -1, 0}
  }, dy[7][3] = {
    {0, 1, 1},
    {1, 2, 3},
    {0, 0, 0},
    {1, 1, 2},
    {0, 1, 1},
    {1, 1, 2},
    {0, 1, 1}
  };
  while(scanf("%s", s[0]) != EOF) {
    for(i = 1; i < 8; ++i) scanf("%s", s[i]);
    int t = 1;
    for(i = 0; i < 8; ++i) {
      for(j = 0; j < 8; ++j) {
        if(s[i][j] == '1') {
          for(k = 0; k < 7; ++k) {
            for(l = 0; l < 3; ++l) {
              if(i + dy[k][l] < 0 || i + dy[k][l] >= 8 || j + dx[k][l] < 0 || j + dx[k][l] >= 8 || s[i + dy[k][l]][j + dx[k][l]] == '0') break;
            }
            if(l == 3) {
              printf("%c\n", 'A' + k);
              break;
            }
          }
          t = 0;
          break;
        }
      }
      if(!t) break;
    }
  }
  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(){
	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 a;
	bool hantei;
	while (cin >> a) {
		int graph[10][10] = {0};
		hantei = false;
		graph[1][1] = a - '0';
		for (int j = 2; j < 9; j++) {
			cin >> a;
			graph[1][j] = a - '0';
		}
		for (int i = 2; i < 9; i++) {
			for (int j = 1; j < 9; j++) {
				cin >> a;
				graph[i][j] = a - '0';
			}
		}
		for (int i = 1; i < 9; i++) {
			for (int j = 1; j < 9; j++) {
				if (graph[i][j] == 1) {
					if (graph[i][j+1] == 1) {
						if (graph[i+1][j+1] == 1) {
							if (graph[i+1][j] == 1) {
								cout << 'A' << endl;
							} else {
								cout << 'E' << endl;
							}
						} else {
							if (graph[i+1][j] == 1) {
								cout << 'G' << endl;
							} else {
								cout << 'C' << endl;
							}
						}
					} else {
						if (graph[i+2][j] == 1) {
							cout << 'B' << endl;
						} else {
							if (graph[i+1][j+1] == 1) {
								cout << 'F' << endl;
							} else {
								cout << 'D' << endl;
							}
						}
					}
					hantei = true;
					break;
				}
			}
			if (hantei == true) {
				break;
			}
		}
	}
	return 0;
}