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(), "")
		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++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct P{ double x, y; };

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


const int target[7][3][2] = 
{
	{{1, 0}, {0, 1}, {1, 1}},
	{{0, 1}, {0, 2}, {0, 3}}, 
	{{1, 0}, {2, 0}, {3, 0}},
	{{0, 1}, {-1,1}, {-1,2}},
	{{1, 0}, {1, 1}, {2, 1}},
	{{0, 1}, {1, 1}, {1, 2}},
	{{1, 0}, {0, 1}, {-1,1}}
};



char solve(vector<string>& field)
{
	rep(x, 8) rep(y, 8) rep(t, 7)
	{
		if(Range(x, y) && field[y][x] == '1')
		{
			rep(p, 3)
			{
				int nx = x + target[t][p][0], ny = y + target[t][p][1];
				if(!Range(nx, ny) || field[ny][nx] != '1')
					break;
				else if(p == 2)
				{
					return 'A' + t;
				}
			}
		}
	}

	return 'Z';
}



int main()
{
	vector<string> f(8);
	while(cin >> f[0] >> f[1] >> f[2] >> f[3] >> f[4] >> f[5] >> f[6] >> f[7])
		cout << solve(f) << endl;	
}

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