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 <cstring>
using namespace std;
struct P {int x, y; char s[4][5];};
char f[8][9] = {{""}};
bool c(int x, int y, P p)
{
	int i, j;
	char t[8][9];
	for (i = 0; i < 8; i++)
		strcpy(t[i], f[i]);
	for (i = 0; i < p.y; i++)
	{
		for (j = 0; j < p.x; j++)
		{
			t[y+i][x+j] = p.s[i][j];
		}
	}
	for (i = 0; i < 8; i++)
		if (strcmp(t[i], f[i]) != 0)
		{
			return false;
		}
	return true;
}
int main()
{
	P p[7] = {2, 2, {"11", "11"},
		1, 4, {"1", "1", "1", "1"},
		4, 1, {"1111"},
		2, 3, {"01", "11", "10"},
		3, 2, {"110", "011"},
		2, 3, {"10", "11", "01"},
		3, 2, {"011", "110"}};
	int i, j, k;
	bool b;
	char res;
	while (!cin.eof())
	{
		for (i = 0; i < 8; i++)
			cin >> f[i];
		cin.get();
		for (i = 0; i < 8; i++)
		{
			for (j = 0; j < 8; j++)
			{
				for (k = 0; k < 7; k++)
				{
					if (8-j >= p[k].x && 8-i >= p[k].y)
						if (b = c(j, i, p[k]))
							res = 'A' + k;
				}
				if (b) break;
			}
			if (b) break;
		}
		cout << res << endl;
	}
}

C++: #include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)

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

int yb[7][3] = {
	{0, 1, 1},
	{1, 2, 3},
	{0, 0, 0},
	{1, 1, 2},
	{0, 1, 1},
	{1, 1, 2},
	{0, 1, 1}
};

int main() {
	string field[8];
	while(getline(cin, field[0])) {
		for(int i = 1; i < 8; i++) getline(cin, field[i]);

		char ans = '\0';
		rep(y,8) {
			rep(x,8) {
				if(field[y][x] == '1') {
					// cerr << "x: " << x << " " << "y: " << y << endl;
					rep(i,8) {
						bool f = true;
						rep(j,3) {
							int nx = x + xb[i][j];
							int ny = y + yb[i][j];
#if 1
							if(!(0 <= nx && nx < 8 && 0 <= ny && ny < 8 && field[ny][nx] == '1')) {
								f = false;
								break;
							}
#endif
						}
						if(f) {
							ans = 'A' + i;
							goto END;
						}
					}
				}
			}
		}
	END:
		cout << ans << endl;
		getline(cin, field[0]);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
char str[9][9];
int mx[4]={1,0,-1,0},my[4]={0,1,0,-1},moving[4];
void serch(int mo,int y,int x)
{
    for(int i=0;i<4;i++){
            if(str[my[i]+y][x+mx[i]]=='1'&&my[i]+y>=0&&my[i]+y<9&&mx[i]+x>=0&&mx[i]+x<9){
                str[my[i]+y][x+mx[i]]='0';
                moving[mo]=i;
                serch(mo+1,y+my[i],x+mx[i]);
            }

    }
}
int main()
{
    int co=0;
    while(cin>>str[0]){
        for(int i=1;i<8;i++)cin>>str[i];
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(str[i][j]=='1'&&co==0){
                    str[i][j]='0';
                    serch(0,i,j);
                    co=1;
                    break;
                }
                else if(str[i][j]=='1'&&co==1)co++;
            }
        }
        if(moving[0]==0&&co!=2){
            if(moving[1]==1){
                if(moving[2]==2)cout<<"A"<<endl;
                else cout<<"E"<<endl;
            }
            else cout<<"C"<<endl;
        }
        else if(moving[0]==1&&co!=2){
            if(moving[1]==0)cout<<"F"<<endl;
            else if(moving[1]==1)cout<<"B"<<endl;
            else cout<<"D"<<endl;
        }
        else cout<<"G"<<endl;
        co=0;
    }
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
char imap[8][9];
static pair<int, int> forms[7][3] = {
    {{0, 1}, {1, 0}, {0, -1}},
    {{1, 0}, {1, 0}, {1, 0}},
    {{0, 1}, {0, 1}, {0, 1}},
    {{1, 0}, {0, -1}, {1, 0}},
    {{0, 1}, {1, 0}, {0, 1}},
    {{1, 0}, {0, 1}, {1, 0}},
    {{0, 1}, {1, -1}, {0, -1}}
};
static char decoder[7] = {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
int res;

bool search(int x, int y, int t) {
    bool isFound = true;
    for (int i = 0; i < 3; i++) {
        x += forms[t][i].first, y += forms[t][i].second;
        if (x < 0 || x > 7 || y < 0 || y > 7 || imap[x][y] != '1') { isFound = false; break; }
    }
    return isFound;
}

void solve() {
    bool flag = false;
    res = -1;
    for (int i = 0; i < 8; i++) {
        if (res > -1) break;
        for (int j = 0; j < 8; j++) {
            if (imap[i][j] == '0') continue;
            for (int k = 0; k < 7; k++) {
                if (search(i, j, k)) { res = k; break;}
            }
            break;
        }
    }
}



int main(){

    while(scanf("%s", imap[0]) != EOF) {
        for (int i = 1; i < 8; i++) {
            scanf("%s", imap[i]);
        }
        solve();
        printf("%c\n", decoder[res]);
    }
    return 0;
}

C++: #include <iostream>
#include <utility>
using namespace std;
typedef pair<int,int> P;
int main(){
	int a;
	char board[8][9];
	P l[4];
	while(cin >> board[0]){
		a = 0;
		for(int i = 1;i < 8;++i){
			cin >> board[i];
		}
		for(int i = 0;i < 8;++i){
			for(int j = 0;j < 8;++j){
				if(board[i][j] == '1'){
					l[a].first = j;
					l[a].second = i;
					++a;
				}
			}
		}
		if(l[3].first - l[0].first == 3){
			cout << 'C' << endl;
		}
		else if(l[3].second - l[0].second == 3){
			cout << 'B' << endl;
		}
		else if(l[3].second - l[0].second == l[3].first - l[0].first){
			cout << 'A' << endl;
		}
		else if(l[0].first == l[3].first){
			cout << 'G' << endl;
		}
		else if(l[3].first - l[0].first == 2){
			cout << 'E' << endl;
		}
		else if(l[3].first - l[0].first == -1){
			cout << 'D' << endl;
		}
		else cout << 'F' << endl;
	}
	return 0;
}