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

C++: #include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;

int main(){
    char boa[8][8];
    while(1){
        
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(!(cin>>boa[i][j]))
                    return 0;
            }
        }
        int bo[8][8];
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                bo[i][j]=boa[i][j]-'0';
            }
        }
            
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(bo[i][j]==1){
                    if(i<7&&j<7){
                        if(bo[i+1][j]==1&&bo[i][j+1]==1&&bo[i+1][j+1]){
                            cout<<"A"<<endl;
                            goto next;
                        }
                    }
                    if(j<5){
                        if(bo[i][j+1]&&bo[i][j+2]&&bo[j+3]){
                            cout<<"C"<<endl;goto next;
                        }
                            
                    }
                    if(i<5){
                        if(bo[i+1][j]&&bo[i+2][j]&&bo[i+3][j]){
                            cout<<"B"<<endl;goto next;
                        }
                        
                    }
                    if(i<7&&i>0&&j<7){
                        if(bo[i+1][j]&&bo[i][j+1]&&bo[i-1][j+1]){
                            cout<<"D"<<endl;goto next;
                        }
                    }
                    if(i<7&&j<6){
                        if(bo[i][j+1]&&bo[i+1][j+1]&&bo[i+1][j+2]){
                            cout<<"E"<<endl;goto next;
                        }
                    }
                    if(i<6&&j<7){
                        if(bo[i+1][j]&&bo[i+1][j+1]&&bo[i+2][j+1]){
                            cout<<"F"<<endl;goto next;
                        }
                    }
                    if(i<7&&j>0&&j<7){
                        if(bo[i+1][j]&&bo[i+1][j-1]&&bo[i][j+1]){
                            cout<<"G"<<endl;goto next;
                        }
                    }
                    
                }
            }
        }
        
    next:;
    }
    
    return 0;
}

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

int main(){
	int ax, ay;
	char f[12][12];
	bool flag = false;

	for(int y=0 ; y<12 ; y++){
		for(int x=0 ; x<12 ; x++){
			f[y][x] = 0;
		}
	}

	while( 1 ){
		for(int i=0 ; i<8 ; i++) {
			if( scanf("%s", f[i]) == EOF ){
				flag = true;
				break;
			}
		}
		if(flag) break;

		for(int i=0 ; i<64 ; i++){
			if(f[i/8][i%8]=='1'){
				ax = i%8;
				ay = i/8;
				break;
			}
		}
		if( f[ay+1][ax]=='1' && f[ay][ax+1]=='1' && f[ay+1][ax+1]=='1' ){
			printf("A\n");
		}else if( f[ay+1][ax]=='1' && f[ay+2][ax]=='1' && f[ay+3][ax]=='1' ){
			printf("B\n");
		}else if( f[ay][ax+1]=='1' && f[ay][ax+2]=='1' && f[ay][ax+3]=='1' ){
			printf("C\n");
		}else if( f[ay][ax+1]=='1' && f[ay+1][ax+1]=='1' && f[ay+1][ax+2]=='1' ){
			printf("E\n");
		}else if( f[ay+1][ax]=='1' && f[ay+1][ax+1]=='1' && f[ay+2][ax+1]=='1' ){
			printf("F\n");
		}else if( f[ay][ax+1]=='1' && f[ay+1][ax]=='1' && f[ay+1][ax-1]=='1' ){
			printf("G\n");
		}else if( f[ay+2][ax-1]=='1' && f[ay+1][ax]=='1' && f[ay+1][ax-1]=='1' ){
			printf("D\n");
		}
	}
}

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];
		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;
		cin.get();
	}
}

C++: #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int getPeace(string s, int& pos)
{
	int c = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s.substr(i, 1) == "1")
		{
			if (c == 0)
			{
				pos = i;
			}
			c++;
		}
	}
	return c;
}

int main()
{
	string s;
	string out = "";
	int p0 = -1;
	int pos0 = -1;
	for (int i = 0; cin >> s; )
	{
		int pos = -1;
		int p = getPeace(s, pos);

		if (out == "")
		{
			if (p == 4)
			{
				out = "C";
			}
			else if (p == 2)
			{
				if (p0 == 2)
				{
					if (pos == pos0)
					{
						out = "A";
					}
					else if (pos > pos0)
					{
						out = "E";
					}
					else
					{
						out = "G";
					}
				}
				else if (p0 == 1)
				{
					if (pos < pos0)
					{
						out = "D";
					}
					else if (pos == pos0)
					{
						out = "F";
					}
				}
			}
			else if (p == 1)
			{
				if (p0 == 1)
				{
					out = "B";
				}
			}
		}

		p0 = p;
		pos0 = pos;

		i++;
		if (i == 8)
		{
			i = 0;
			cout << out << endl;
			out = "";
			p0 = -1;
			pos0 = -1;
		}
	}

}