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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MAX_N 5001
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;
typedef vector<ll> V;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string f[10];

int main(){
	while (cin >> f[0]){
		FOR(i, 1, 8){
			cin >> f[i];
		}
		REP(i, 8){
			REP(j, 8){
				if (f[i][j] == '1'){
					if (i+3<8&&f[i + 3][j] == '1'){
						cout << 'B' << endl;
					}
					if (j+3<8&&f[i][j + 3] == '1'){
						cout << 'C' << endl;
					}
					if (i + 2 < 8 && j - 1 >= 0 && f[i + 2][j - 1] == '1'){
						cout << 'D' << endl;
					}
					if (i + 2 < 8 && j + 1 < 8 && f[i + 2][j + 1] == '1'){
						cout << 'F' << endl;
					}
					if (i + 1 < 8 && j + 1 < 8 &&
						f[i + 1][j] == '1'&&f[i][j + 1] == '1'&&f[i + 1][j + 1] == '1'){
						cout << 'A' << endl;
					}
					if (i + 1 < 8 && j + 2 < 8 && f[i + 1][j + 2] == '1'){
						cout << 'E' << endl;
					}
					if (i + 1 < 8 && j - 1 >= 0 && j + 1 < 8 &&
						f[i + 1][j - 1] == '1'&&f[i][j + 1] == '1'){
						cout << 'G' << endl;
					}
					break;
				}
			}
		}
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
    char b[8][8];
    int a[8][8];
    char en;
int main(void){
 
 
 
    while(cin>>b[0]){
        cin>>b[1]>>b[2]>>b[3]>>b[4]>>b[5]>>b[6]>>b[7];
 
 
    for(int n=0;n<8;n++){
        for(int m=0;m<8;m++){
            if(b[n][m]=='1')a[n][m]=1;
            else a[n][m]=0;
        }
    }
    int i,j;
    int flag=0;
    char t;
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(a[i][j]==1){
             //   cout<<i<<j;
                flag=1;
                break;
            }
        }
        if(flag==1)break;
    }
    if(a[i][j]==a[i][j+1]){
        //cout<<".";
        if(a[i][j+1]==a[i][j+2])t='C';
        else if(a[i][j+1]==a[i+1][j]){
            if(a[i+1][j]==a[i+1][j+1])t='A';
            else if(a[i+1][j]==a[i+1][j-1])t='G';
        }
        else if(a[i][j+1]==a[i+1][j+2])t='E';
    }
    else if(a[i][j]==a[i+1][j]){
        if(a[i+1][j]==a[i+2][j])t='B';
        else if(a[i+1][j]==a[i+1][j+1])t='F';
        else if(a[i+1][j]==a[i+1][j-1])t='D';
    }
    //else cout<<".....";
 
    cout<<t<<endl;
 
 
    }
 
    return 0;
}

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