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 <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	while(1){
		char field[8][9];
		int left = 8, right = 0, top = 8, bottom = 0;
		rep(y, 8){
			if(scanf("%s", field[y]) == EOF)
				return 0;
			rep(x, 8){
				if(field[y][x] == '1'){
					left = min(left, x);
					right = max(right, x);
					top = min(top, y);
					bottom = max(bottom, y);
				}
			}
		}

		int w = right - left + 1, h = bottom - top + 1;
		if(h==4)
			puts("B");
		else if(w==4)
			puts("C");
		else if(w==2 && w==2)
			puts("A");
		else if(w==2 && h==3)
			puts(field[top][left] == '1' ? "F" : "D");
		else
			puts(field[top][left] == '1' ? "E" : "G");
	}
}

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

vector <string> f;

const string P[7][4] = {
	{// A
		"1100",
		"1100",
		"0000",
		"0000"
	},
	{// B
		"1000",
		"1000",
		"1000",
		"1000"
	},
	{// C
		"1111",
		"0000",
		"0000",
		"0000"
	},
	{// D
		"0100",
		"1100",
		"1000",
		"0000"
	},
	{// E
		"1100",
		"0110",
		"0000",
		"0000"
	},
	{// F
		"1000",
		"1100",
		"0100",
		"0000"
	},
	{// G
		"0110",
		"1100",
		"0000",
		"0000"
	},
};

bool check( int x, int y, int k )
{
	for ( int i = 0; i < 4; i++ )
	{
		for ( int j = 0; j < 4; j++ )
		{
			int nx = x + j;
			int ny = y + i;
			if ( P[k][i][j] == '1' )
			{
				if ( nx < 0 || nx > 8 || ny < 0 || ny > 8 )
				{
					return false;
				}
				if ( P[k][i][j] != f[ny][nx] )
					return false;
			}
		}
	}
	return true;
}

int main( void )
{
	while ( cin.eof() == false )
	{
		f = vector <string>(8);
		string line;
		for ( int i = 0; i < 8; i++ )
		{
			getline( cin, line );
			f[i] = line;
			if ( cin.eof() ) break;
		}
		if ( cin.eof() ) break;
		getline( cin, line );

		char answer = 'A';
		bool not_found = true;
		for ( int i = 0; not_found && i < 8; i++ )
		{
			for ( int j = 0; not_found && j < 8; j++ )
			{
				for ( int k = 0; not_found && k < 7; k++ )
				{
					if ( check( i, j, k ) )
					{
						answer += k;
						not_found = false;
					}
				}
			}
		}

		cout << answer << endl;
	}
	return 0;
}

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

int main(){

  string s[10];

  while(cin >> s[0]){
    for(int i=1;i<8;i++) cin >> s[i];

    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){

	if(s[i][j] == '1'){
	  if(s[i][j+1] == '1' && s[i+1][j] == '1' && s[i+1][j+1] == '1') cout << 'A' << endl;
	  else if(s[i+1][j] == '1' && s[i+2][j] == '1' && s[i+3][j] == '1') cout << 'B' << endl;
	  else if(s[i][j+1] == '1' && s[i][j+3] == '1' && s[i][j+3] == '1') cout << 'C' << endl;
	  else if(s[i+1][j-1] == '1' && s[i+1][j] == '1' && s[i+2][j-1] == '1') cout << 'D' << endl;
	  else if(s[i][j+1] == '1' && s[i+1][j+1] == '1' && s[i+1][j+2] == '1') cout << 'E' << endl;
	  else if(s[i+1][j] == '1' && s[i+1][j+1] == '1' && s[i+2][j+1] == '1') cout << 'F' << endl;
	  else if(s[i][j+1] == '1' && s[i+1][j-1] == '1' && s[i+1][j] == '1') cout << 'G' << endl;
	}

      }
    }
  }
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int cnt=0,x,y;
	char zero;
	while(cin>>zero){
		char masu[8][8];
		cnt=0;
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(i==0&&j==0){
					masu[0][0]=zero;
				}else{
					cin>>masu[i][j];
				}
				if(masu[i][j]=='1'&&cnt==0){
					x=i,y=j;
					cnt++;
				}
			}
		}
		if(masu[x][y+1]=='1'){
			if(masu[x][y+2]=='1'){
				cout<<"C"<<endl;
			}else if(masu[x+1][y]=='0'){
				cout<<"E"<<endl;
			}else if(masu[x+1][y+1]=='0'){
				cout<<"G"<<endl;
			}else{
				cout<<"A"<<endl;
			}
		}else{
			if(masu[x+1][y-1]=='1'){
				cout<<"D"<<endl;
			}else if(masu[x+1][y+1]=='1'){
				cout<<"F"<<endl;
			}else{
				cout<<"B"<<endl;
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
char data[8][8];


struct P{
	P(){};
	P(int a,int b){
		x=a;
		y=b;
	}
	int x,y;
};

bool input(){
	for(int i=0;i<8;i++){
		if( scanf( "%s",data[i] ) == EOF )return false;
	}
	return true;
}
int main(){
	
	while(input()){
		P o;
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(data[i][j]=='1'){
					o=P(j,i);
					goto suc;
				}
			}
		}
		suc:;
		{
			for(int i=0;i<2;i++){
				for(int j=0;j<2;j++){
					if(o.y+i>=8 || o.x+j>=8)goto fail1;
					if(data[o.y+i][o.x+j]!='1')goto fail1;
				}
			}
			cout<<"A"<<endl;
			continue;
			fail1:;
		}
		{
			for(int i=0;i<4;i++){
				if(o.y+i>=8)goto fail2;
				if(data[o.y+i][o.x]!='1')goto fail2;
			}
			cout<<"B"<<endl;
			continue;
			fail2:; 
		}
		{
			for(int i=0;i<4;i++){
				if(o.x+i>=8)goto fail3;
				if(data[o.y][o.x+i]!='1')goto fail3;
			}
			cout<<"C"<<endl;
			continue;
			fail3:;
		}
		{
			if(o.y+2>=8 || o.x-1<=0)goto fail4;
			if(data[o.y+1][o.x]!='1')goto fail4;
			if(data[o.y+1][o.x-1]!='1')goto fail4;
			if(data[o.y+2][o.x-1]!='1')goto fail4;
			cout<<"D"<<endl;
			continue;
			fail4:;
		}
		{
			if(o.x+2>=8 || o.y+1>=8)goto fail5;
			if(data[o.y][o.x+1]!='1')goto fail5;
			if(data[o.y+1][o.x+1]!='1')goto fail5;
			if(data[o.y+1][o.x+2]!='1')goto fail5;
			cout<<"E"<<endl;
			continue;
			fail5:;
		}
		{
			if(o.x+1>=8 || o.y+2>=8)goto fail6;
			if(data[o.y+1][o.x]!='1')goto fail6;
			if(data[o.y+1][o.x+1]!='1')goto fail6;
			if(data[o.y+2][o.x+1]!='1')goto fail6;
			cout<<"F"<<endl;
			continue;
			fail6:;
		}
		{
			cout<<"G"<<endl;
		}
	}
}