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<algorithm>
using namespace std;

bool vd(int x, int y){
	return x>=0 && y>=0 && y<8 && x<8;
}

char solve(char sol[6]){
//	for(int x=0;x<6;++x)cout<<sol[x]<<" ";
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='0' && sol[3]=='0' && sol[4]=='1' && sol[5]=='1')return 'F';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='1' && sol[3]=='1' && sol[4]=='1' && sol[5]=='0')return 'G';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='1' && sol[3]=='0' && sol[4]=='0' && sol[5]=='1')return 'E';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='0' && sol[3]=='1' && sol[4]=='1' && sol[5]=='0')return 'D';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='1' && sol[3]=='0' && sol[4]=='0' && sol[5]=='0')return 'C';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='0' && sol[3]=='0' && sol[4]=='1' && sol[5]=='0')return 'B';
	return 'A';
}

int main(){
	char j;
	char mat[8][8];
	while(cin>>j){
		pair<int,int> init = make_pair(-1,-1);
		mat[0][0] = j;
		if(j=='1'){
			init.first = 0;init.second = 0;
		}
		for(int x=1;x<64;++x){
			cin>>j;mat[x/8][x%8] = j;
			if(j=='1' && init.first == -1){
				init.first = x/8;
				init.second = x%8;

			}
		}
		//cout<<init.first<<":"<<init.second<<endl;
		char sol[6];
		int cnt = 0;
		for(int x=0;x<2;++x){
			for(int y=-1;y<2;++y){
				if(vd(init.first + x , init.second + y)){
					sol[cnt++] = mat[init.first + x][init.second + y];
				}else{
					sol[cnt++] = '0';
				}
			}
		}
		cout<<solve(sol)<<endl;
	}		
	return 0;
}

C++: #include <cstdio>
using namespace std;

int main(){
	char ch[10][10];
	bool judged;
	
	while((scanf("%s", ch[0])) != EOF){
		for(int i = 1; i < 8; i++){
				scanf("%s", ch[i]);
		}
		
		judged = false;
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				if(ch[i][j] == '1'){
					//A
					if(i + 1 < 8 && ch[i + 1][j] == '1' &&
					 j + 1 < 8 && ch[i][j + 1] == '1' &&
					 ch[i + 1][j + 1] == '1'){
						printf("A\n");
						judged = true;
						break;
					}
					//B
					if(i + 3 < 8 && ch[i + 1][j] == '1' &&
					 ch[i + 2][j] == '1' && ch[i + 3][j] == '1'){
						printf("B\n");
						judged = true;
						break;
					}
					//C
					if(j + 3 < 8 && ch[i][j + 1] == '1' &&
					 ch[i][j + 2] == '1' && ch[i][j + 3] == '1'){
						printf("C\n");
						judged = true;
						break;
					}
					//D
					if(i + 2 < 8 && j - 1 >= 0 &&
					 ch[i + 1][j - 1] == '1' && ch[i + 1][j] == '1' &&
					 ch[i + 2][j - 1] == '1'){
						printf("D\n");
						judged = true;
						break;
					}
					//E
					if(i + 1 < 8 && j + 2 < 8 &&
					 ch[i][j + 1] == '1' && ch[i + 1][j + 1] == '1' &&
					 ch[i + 1][j + 2] == '1'){
						printf("E\n");
						judged = true;
						break;
					}
					//F
					if(i + 2 < 8 && j + 1 < 8 &&
					 ch[i + 1][j] == '1' && ch[i + 1][j + 1] == '1' &&
					 ch[i + 2][j + 1] == '1'){
						printf("F\n");
						judged = true;
						break;
					}
					//G
					if(i + 1 < 8 && j + 1 < 8 && j - 1 >= 0 &&
					 ch[i + 1][j] == '1' && ch[i][j + 1] == '1' &&
					 ch[i + 1][j - 1] == '1'){
						printf("G\n");
						judged = true;
						break;
					}
				}
			}
			
			if(judged) break;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#define MAX 8
using namespace std;

int main(void){
  vector<vector<char> > inp(8,vector<char>(8));
  vector<vector<int> > buf(8,vector<int>(8));
  while(cin>>inp[0][0]){
    buf[0][0]=inp[0][0]-'0';
    for(int i = 1 ; i < 8 ; i ++){
      cin>>inp[0][i];
      buf[0][i]=inp[0][i]-'0';
    }
    for(int i = 1 ; i < 8 ; i ++)
      for(int j = 0 ; j < 8 ; j ++){
        cin>>inp[i][j];
        buf[i][j]=inp[i][j]-'0'; 
      }
//cout<<buf[0][3]<<" "<<buf[0][6]<<endl;
    
    bool find=false;
    char ans;
    for(int i = 0 ; i < 8 ; i ++){
      if(find)break;
      for(int j = 0 ; j < 8 ; j ++){
        if(buf[i][j]){
          ans='O';
          if(0<=i&&i<=MAX-1 && 0<=j&&j<=MAX-1&&buf[i+1][j]&&buf[i][j+1]&&buf[i+1][j+1])ans='A';
          else if(0<=i&&i<=MAX-3 && 0<=j&&j<=MAX&&buf[i+3][j])ans='B';
          else if(0<=i&&i<=MAX && 0<=j&&j<=MAX-3&&buf[i][j+3])ans='C';
          else if(0+1<=i&&i<=MAX-1 && 0<=j&&j<=MAX-2&&buf[i-1][j+2])ans='D';
          else if(0<=i&&i<=MAX-1 && 0<=j&&j<=MAX-2&&buf[i+1][j+2])ans='E';
          else if(0<=i&&i<=MAX-2 && 0<=j&&j<=MAX-1&&buf[i+2][j+1])ans='F';
          else if(0+1<=i&&i<=MAX-1 && 0<=j&&j<=MAX-1&&buf[i][j+1]&&buf[i+1][j-1])ans='G';
          find = true;
          break;
        } 
      }
    }
    cout<<ans<<endl;
    
  }
}