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
}

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++: #define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 8
#define MIN -100001
#define _MAX 8
int main(void)
{
	char a[MAX][MAX + 1], ans;
	int ki, kj,bo = 1;
	while (bo) {
		for (int i = 0; i < MAX; ++i) {
			if (scanf_s("%s", a[i]) == EOF) {
				bo = 0; break;
			}
			for (int j = 0; j < MAX; ++j) {
				if (a[i][j] == '1') {
					ki = i; kj = j;
				}
			}
		}//a,b,d,f,g
		if (bo == 0) break;
		if (ki - 1 >= 0 && a[ki - 1][kj] == '1') {
			if (ki - 2 >= 0 && a[ki - 2][kj] == '1') ans = 'B';
			else {//a,d,f,g
				if (kj - 1 < MAX && a[ki][kj - 1] == '1') {//a,g,
					if (a[ki - 1][kj - 1] == '1') ans = 'A';
					else ans = 'G';
				}
				else {//f,g
					if (kj - 1 < MAX && a[ki - 1][kj - 1] == '1') ans = 'F';
					else ans = 'G';
				}
			}
		}//c,e
		else {
			if (kj - 2 >= 0 && a[ki][kj - 2] == '1') ans = 'C';
			else ans = 'E';
		}
		printf("%c\n", ans);
	}
}

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

int dt[24][24];

int num=0;

bool checkA(int i,int j){
	if(dt[i+1][j]==1 && dt[i][j+1]==1 && dt[i+1][j+1]==1 && dt[i][j]==1)return true;
	else if(dt[i][j-1]==1 && dt[i+1][j-1]==1 && dt[i+1][j]==1 && dt[i][j]==1)return true;
	else if(dt[i-1][j]==1 && dt[i-1][j+1]==1 && dt[i][j+1]==1 && dt[i][j]==1)return true;
	else if(dt[i-1][j-1]==1 && dt[i][j-1]==1 && dt[i-1][j]==1 && dt[i][j]==1)return true;
	else return false;
}

bool checkB(int  i,int j){
	if(dt[i+1][j]==1 && dt[i+2][j]==1 && dt[i+3][j]==1 && dt[i][j]==1)return true;
	else if(dt[i-1][j]==1 && dt[i+1][j]==1 && dt[i+2][j]==1 && dt[i][j]==1)return true;
	else if(dt[i-2][j]==1 && dt[i-1][j]==1 && dt[i+1][j]==1 && dt[i][j]==1)return true;
	else if(dt[i-3][j]==1 && dt[i-2][j]==1 && dt[i-1][j]==1 && dt[i][j]==1)return true;
	else return false;
}

bool checkC(int i,int j){
	if(dt[i][j]==1){
		if(dt[i][j+1]==1 && dt[i][j+2]==1 && dt[i][j+3]==1)return true;
		else if(dt[i][j-1]==1 && dt[i][j+1]==1 && dt[i][j+2]==1)return true;
		else if(dt[i][j-2]==1 && dt[i][j-1]==1 && dt[i][j+1]==1)return true;
		else if(dt[i][j-3]==1 && dt[i][j-2]==1 && dt[i][j-1]==1)return true;
		else return false;
	}else return false;
}

bool checkD(int i,int j){
	if(dt[i][j]==1){
		if(dt[i+1][j]==1 && dt[i+1][j-1]==1 && dt[i+2][j-1]==1)return true;
		else if(dt[i-1][j]==1 && dt[i][j-1]==1 && dt[i+1][j-1]==1)return true;
		else if(dt[i][j+1]==1 && dt[i-1][j+1]==1 && dt[i+1][j]==1)return true;
		else if(dt[i-1][j]==1 && dt[i-1][j+1]==1 && dt[i-2][j+1]==1)return true;
		else return false;
	}else return false;
}

bool checkE(int i,int j){
	if(dt[i][j]==1){
		if(dt[i][j+1]==1 && dt[i+1][j+1]==1 && dt[i+1][j+2]==1)return true;
		else if(dt[i][j-1]==1 && dt[i+1][j]==1 && dt[i+1][j+1]==1)return true;
		else if(dt[i-1][j]==1 && dt[i-1][j-1]==1 && dt[i][j+1]==1)return true;
		else if(dt[i][j-1]==1 && dt[i-1][j-1]==1 && dt[i-1][j-2]==1)return true;
		else return false;
	}else return false;
}

bool checkF(int i,int j){
	if(dt[i][j]==1){
		if(dt[i+1][j]==1 && dt[i+1][j+1]==1 && dt[i+2][j+1]==1)return true;
		else if(dt[i-1][j]==1 && dt[i][j+1]==1 && dt[i+1][j+1]==1)return true;
		else if(dt[i][j-1]==1 && dt[i-1][j-1]==1 && dt[i+1][j]==1)return true;
		else if(dt[i-1][j]==1 && dt[i-1][j-1]==1 && dt[i-2][j-1]==1)return true;
		else return false;
	}else return false;
}

bool checkG(int i,int j){
	if(dt[i][j]==1){
		if(dt[i][j+1]==1 && dt[i+1][j]==1 && dt[i+1][j-1]==1)return true;
		else if(dt[i][j-1]==1 && dt[i+1][j-1]==1 && dt[i+1][j-2]==1)return true;
		else if(dt[i-1][j]==1 && dt[i-1][j+1]==1 && dt[i][j-1]==1)return true;
		else if(dt[i][j+1]==1 && dt[i-1][j+1]==1 && dt[i-1][j+2]==1)return true;
		else return false;
	}else return false;
}

int main(){
	string ss;
	while(1){
		for(int i=0;i<24;i++){
			for(int j=0;j<24;j++){
				dt[i][j]=0;
			}
		}
		for(int i=8;i<16;i++){
			if(cin>>ss)return 0;
			for(int j=8;j<16;j++){
				dt[i][j]=ss[j-8]-'0';
			}
		}
		for(int a=8;a<16;a++){
			for(int b=8;b<16;b++){
				if(!num){
					if(checkA(a,b)){cout<<"A"<<endl;num++;}
					else if(checkB(a,b)){cout<<"B"<<endl;num++;}
					else if(checkC(a,b)){cout<<"C"<<endl;num++;}
					else if(checkD(a,b)){cout<<"D"<<endl;num++;}
					else if(checkE(a,b)){cout<<"E"<<endl;num++;}
					else if(checkF(a,b)){cout<<"F"<<endl;num++;}
					else if(checkG(a,b)){cout<<"G"<<endl;num++;}
				}
			}
		}
	}
	return 0;
}

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

int main(){
	char f[9][9];
	while(1){
		bool flag=false;
		
		for(int i=0; i<8; ++i){
			for(int j=0; j<8; ++j){
				if( scanf(" %c", &f[i][j])==EOF){
					flag=true;
					break;
				}
			} 
			if(flag) break;	
		}
		if(flag) break;

		bool ans=false;
		char c='1';
		for(int i=0; i<8; ++i){
			for(int j=0; j<8; ++j){
				
				if(f[j][i]==c){
					if(i<=6 && j<=6 && f[j+1][i]==c && f[j][i+1]==c && f[j+1][i+1]==c){
						printf("A\n");	
						ans=true;
						break;
					}
					else if(j<=4 && f[j+1][i]==c && f[j+2][i]==c && f[j+3][i]==c){
						printf("B\n");	
						ans=true;
						break;
					}
					else if(i<=4 && f[j][i+1]==c && f[j][i+2]==c && f[j][i+3]==c){
						printf("C\n");	
						ans=true;
						break;
					}
					else if(1<=j && j<=6 && i<=6 && f[j+1][i]==c && f[j][i+1]==c && f[j-1][i+1]==c){
						printf("D\n");	
						ans=true;
						break;
					}
					else if(j<=5 && i<=6 && f[j][i+1]==c && f[j+1][i+1]==c && f[j+1][i+2]==c){
						printf("E\n");	
						ans=true;
						break;
					}
					else if(j<=5 && i<=6 && f[j+1][i]==c && f[j+1][i+1]==c && f[j+2][i+1]==c){
						printf("F\n");	
						ans=true;
						break;
					}
					else if(1<=j && i<=5 && f[j][i+1]==c && f[j-1][i+1]==c && f[j-1][i+2]==c){
						printf("G\n");	
						ans=true;
						break;
					}
											
				}
	
			}
			if(ans) break;
		}
			
	}
}