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>
using namespace std;
int m[10][10]={0},a[5],k=0;

void dfs(int i,int j){
  if(m[i-1][j]==1){
    m[i-1][j]=0;
    a[k]=1;
    //cout<<"1"<<" ";////
    k++;
    dfs(i-1,j);
  }
  if(m[i][j-1]==1){
    //  cout<<"2"<<" ";////
    m[i][j-1]=0;
    a[k]=2;
    k++;
    dfs(i,j-1);
  }
  if(m[i+1][j]==1){
    //    cout<<"3"<<" ";////
    m[i+1][j]=0;
    a[k]=3;
    k++;
    dfs(i+1,j);  
  }
  if(m[i][j+1]==1){
    //    cout<<"4"<<" ";////
    m[i][j+1]=0;
    a[k]=4;
    k++;
    dfs(i,j+1); 
  }  
}

int main(){
  int ih=0,jh=0;
  char s;
  while(cin>>s){
    k=0;
    m[1][1]=s-'0';
    for(int i=1;i<=8;i++){
      for(int j=1;j<=8;j++){
	//cout<<i<<" "<<j<<endl;/////
	if(i==1&&j==1)continue;
	else cin>>s;
	m[i][j]=s-'0';
	
	if(m[i][j]==1){
	  ih=i;
	  jh=j;
	}
	
      }
    }
    m[ih][jh]=0;
    dfs( ih , jh );
    //cout<<endl<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;////
    if(a[0]==1&&a[1]==2&&a[2]==3)cout<<"A"<<endl;
    else if(a[0]==1&&a[1]==1&&a[2]==1)cout<<"B"<<endl;
    else if(a[0]==2&&a[1]==2&&a[2]==2)cout<<"C"<<endl;
    else if(a[0]==1&&a[1]==4&&a[2]==1)cout<<"D"<<endl;
    else if(a[0]==2&&a[1]==1&&a[2]==2)cout<<"E"<<endl;
    else if(a[0]==1&&a[1]==2&&a[2]==1)cout<<"F"<<endl;
    else if(a[0]==1&&a[1]==4&&a[2]==2)cout<<"G"<<endl;

  }
  return 0;
}

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)

using namespace std;

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

string ptn[7] = {	"1100110000000000",
					"1000100010001000",
					"1111000000000000",
					"0100110010000000",
					"1100011000000000",
					"1000110001000000"
					"0110110000000000"};

int main(){
	
	while(1){
		char ans = 0;
		string str;
		vector<string> surf = vector<string>(16, "0000000000000000");
		
		for(int i = 0; i < 8; ++i){
		
			if(cin.eof())
				return 0;
			
			cin >> str;
			surf[i] = str+"0000";
			
		}
		
		for(int y = 0; y < 8; ++y){
			for(int x = 0; x < 8; ++x){
				
				if(surf[y][x] == '1'){
					for(int k = 0; k < 7; ++k){
						
						int cnt = 0;
						
						for(int i = 0; i < 16; ++i){
							if( ptn[k][i] == surf[y+i/4][x+i%4] )
								cnt++;
							else
								break;
						}
						
						if(cnt>=16){
							ans = char('A'+k);
							goto out;
						}
						
					}
				}
				
			}
		}
		
		out:
			if(ans)
				cout << ans << endl;
	}
}

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

int main(){

	string str[8];
	int valid;

	while(cin >> str[0]){
		for(int i=1; i<8; i++){
			cin >> str[i];
		}
		
		valid = 0;
		for(int i=0; i<8 && valid == 0; i++){
			for(int j=0; j<8; j++){
				if(str[i][j] == '1'){
					if(i <= 4 && str[i+3][j] == '1'){
						cout << 'B' << endl;
						valid = 1;
						break;
					}
					if(j <= 4 && str[i][j+3] == '1'){
						cout << 'C' << endl;
						valid = 1;
						break;
					}
					if(j != 0 && i <= 5 && str[i+2][j-1] == '1'){
						cout << 'D' << endl;
						valid = 1;
						break;
					}
					if(j <= 5 && i != 7 && str[i+1][j+2] == '1'){
						cout << 'E' << endl;
						valid = 1;
						break;
					}
					if(j != 7 && i <= 5 && str[i+2][j+1] == '1'){
						cout << 'F' << endl;
						valid = 1;
						break;
					}
					if(j != 0 && i != 7 && str[i+1][j-1] == '1'){
						cout << 'G' << endl;
						valid = 1;
						break;
					}
					cout << 'A' << endl;
					valid = 1;
					break;
				}
			}
		}
	}

	return 0;

}

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;
				}
			}
		}
	}
}