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 < 8; i++ {
			for j := 0; j < 8; 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 < 8; 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 < 8; 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 < 8; i++ {
			for j := 0; j < 8; 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 < 8; i++ {
			for j := 0; j < 8; 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 < 8; i++ {
			for j := 0; j < 8; 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 < 8; i++ {
			for j := 0; j < 8; 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<string>
using namespace  std;

string table[8];
bool range(int y,int x)
{
	if (y < 0 || x < 0 || y >= 8 || x >= 8)return false;
	return true;
}
bool A(int y, int x)
{
	int dx[] = {0,1,1,0};
	int dy[] = {0,0,1,1};
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool B(int y, int x)
{
	int dx[] = { 0, 0, 0, 0 };
	int dy[] = { 0, 1, 2, 3 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool C(int y, int x)
{
	int dx[] = { 0, 1, 2, 3 };
	int dy[] = { 0, 0, 0, 0 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool D(int y, int x)
{
	int dx[] = { 0, 0, -1, -1 };
	int dy[] = { 0, 1,1, 2 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool E(int y, int x)
{
	int dx[] = { 0, 1, 1, 2 };
	int dy[] = { 0, 0, 1, 1 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool F(int y, int x)
{
	int dx[] = { 0, 0, 1, 1 };
	int dy[] = { 0, 1, 1, 2 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool G(int y, int x)
{
	int dx[] = { 0, 1, 0, -1 };
	int dy[] = { 0, 0, -1, -1 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
char check(int y, int x)
{
	if (A(y, x))return 'A';
	else if (B(y, x))return 'B';
	else if (C(y, x))return 'C';
	else if (D(y, x))return 'D';
	else if (E(y, x))return 'E';
	else if (F(y, x))return 'F';
	else if (G(y, x)) return 'G';
	else return 0;
}
int main()
{
	while (true)
	{
		for (int i = 0; i < 8; i++)
		{
			if (!(cin >> table[i]))return 0;
		}
		bool find = false;
		for (int i = 0; i < 8; i++)
		{
			for (int j = 0; j < 8; j++)
			{
				int ret = check(i,j);
				if (ret > 0)
				{
					find = true;
					cout << ((char)ret) << endl;
					break;
				}
			}
			if (find)break;
		}
	}
	return 0;
}

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

string M[8];

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

int main() {

  while(cin>>M[0]) {
    for(int i=1; i<8; i++) cin >> M[i];
    
    char res = '#';
    
    for(int i=0; i<8; i++) {
      for(int j=0; j<8; j++) {
	if(M[i][j]-'0') {
	  
	  if(inF(i+1, j+1) && M[i+1][j+1]-'0') {
	    if(inF(i+2, j+1) && M[i+2][j+1]-'0') {
	      res = 'F'; goto end;
	    } else if(inF(i+1, j+2) && M[i+1][j+2]-'0') {
	      res = 'E'; goto end;
	    } else {
	      res = 'A'; goto end;
	    }
	  }
	  
	  if(inF(i+3, j) && M[i+3][j]-'0') {
	    res = 'B'; goto end;
	  }

	  if(inF(i, j+3) && M[i][j+3]-'0') {
	    res = 'C'; goto end;
	  }

	  if(inF(i+1, j-1) && M[i+1][j-1]-'0') {
	    if(inF(i, j+1) && M[i][j+1]-'0') {
	      res = 'G'; goto end;
	    } else {
	      res = 'D'; goto end;
	    }
	  }
	}
      }
    }
    end:
    cout << res << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    while (true)
    {
        string a[8];
        vector<int> tracex;
        vector<int> tracey;
        bool flag = false;
        rep(i, 8)
        {
            cin >> a[i];
            if (cin.eof())
                flag = true;
        }
        rep(i, 8)
            rep(j, 8) if (a[i][j] == '1')
        {
            tracex.push_back(j);
            tracey.push_back(i);
        }
        REP(i, 1, tracex.size())
        tracex[i] -= tracex[0];
        REP(i, 1, tracey.size())
        tracey[i] -= tracey[0];
        //tracex[0]=0;tracey[0]=0;
        if(DEBUG)rep(i, tracey.size()) cout << tracex[i] << ":" << tracey[i] << endl;
        if (tracex[3] == 1 && tracey[3] == 1)
            cout << "A" << endl;
        if (tracex[3] == 3)
            cout << "C" << endl;
        if (tracey[3] == 3)
            cout << "B" << endl;
        if (tracex[1] == -1 && tracey[3] == 2)
            cout << "D" << endl;
        if (tracex[3] == 2)
            cout << "E" << endl;
        if (tracex[1] == 1 && tracey[3] == 2)
            cout << "F" << endl;
        if (tracex[2] == -1 && tracey[2] == 1)
            cout << "G" << endl;
        if (flag)
            break;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
string match(const vector<string> v){
	const string PTN[7][4]{
		{"11","11"},
		{"1","1","1","1"},
		{"1111"},
		{"01","11","10"},
		{"110","011"},
		{"10","11","01"},
		{"011","110"}
	};
	const int PTN_H[7]{2,4,1,3,2,3,2};
	const string PTN_NAME[7]={"A","B","C","D","E","F","G"};
	int ans=-1;
	for(int k=0;k<7;++k){
		int pw=PTN[k][0].size(),ph=PTN_H[k];
		for(int i=0;i<8;++i){
			for(int j=0;j<8;++j){
				if(i+ph<8&&j+pw<=8){//substrなので含む
					bool f=true;
					for(int l=0;l<ph;++l){
						if(PTN[k][l]!=v[i+l].substr(j,pw))f=false;
					}
					if(f){ans=k;break;break;break;}
				}else{
					break;
				}
			}
		}
	}
	return PTN_NAME[ans];
}
int main(){
	for(;;){
		vector<string> surface;
		for(int i=0;i<8;++i){
			string s;
			cin>>s;
			if(s.empty())return 0;
			surface.push_back(s);
		}
		string ans = match(surface);
		cout<<ans<<endl;
		if(cin.eof())break;
	}
	return 0;
}