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
}

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 <iostream>

using namespace std;

int img[8][8];

int checker(int i, int j) {
  if (0 <= i && i < 8 && 0 <= j && j < 8) {
    return img[i][j];
  } else {
    return 0;
  }
}

int main() {
  while (!cin.eof()) {
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (cin.eof()) return 0;
        char c;
        cin >> c;
        img[i][j] = c - '0';
      }
    }
    bool flag = false;
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (checker(i, j)) {
          if (checker(i,j+1) && checker(i+1,j) && checker(i+1,j+1)) {
            cout << 'A' << endl;
          } else if (checker(i+1,j) && checker(i+2,j) && checker(i+3,j)) {
            cout << 'B' << endl;
          } else if (checker(i,j+1) && checker(i,j+2) && checker(i,j+3)) {
            cout << 'C' << endl;
          } else if (checker(i+1,j) && checker(i+1,j-1) && checker(i+2,j-1)) {
            cout << 'D' << endl;
          } else if (checker(i,j+1) && checker(i+1,j+1) && checker(i+1,j+2)) {
            cout << 'E' << endl;
          } else if (checker(i+1,j) && checker(i+1,j+1) && checker(i+2,j+1)) {
            cout << 'F' << endl;
          } else if (checker(i,j+1) && checker(i+1,j) && checker(i+1,j-1)) {
            cout << 'G' << endl;
          } 
          flag = true;
          break;
        }
      }
      if (flag) break;
    }
  }


  return 0;
}

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];
		getc(stdin);
		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;
				}
			}
		}
		cout << res << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	while (!cin.eof) {
		char c[8][8];
		for (int i = 0; i < 8; i++)
			for (int j = 0; j < 8; j++)
				cin >> c[i][j];
		int a, b;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (c[i][j] == '1') {
					a = i;
					b = j;
					goto C;
				}
			}
		}
	C:
		if (c[a][b + 1] == '1') 
			if (c[a + 1][b] == '1') 
				if (c[a + 1][b + 1] == '1')
					cout << 'A';
				else cout << 'G';
			else
				if (c[a + 1][b + 1] == '1')
					cout << 'E';
				else cout << 'C';
		else if (c[a + 1][b + 1] == '1')
			cout << 'F';
		else if (c[a - 1][b + 1] == '1')
			cout << 'D';
		else cout << 'C';
		cout << endl;
	}
}

C++: #include <iostream>

struct 
{} undefined;

template <typename T , unsigned H , unsigned W>
auto input (T (& a) [H] [W]) -> bool
{
    bool result = static_cast <bool> (std::cin >> a [0] [0]);
    if (! result)
    {
        return false;
    }
    for (auto x = 1u; x < W; ++ x)
    {
        std::cin >> a [0] [x];
    }
    for (auto y = 1u; y < H; ++ y)
    {
        for (auto x = 0u; x < W; ++ x)
        {
            std::cin >> a [y] [x];
        }
    }
    return true;
}

template <unsigned H , unsigned W>
auto at (char (& a) [H] [W] , unsigned x , unsigned y) -> bool
{
    if (0 <= x && x < W && 0 <= y && y < H)
    {
        return a [y] [x] == '1';
    }
    else
    {
        return false;
    }
}

template <unsigned H , unsigned W>
auto check (char (& a) [H] [W]) -> char
{
    for (auto y = 0u; y < H; ++ y)
    {
        for (auto x = 0u; x < W; ++ x)
        {
            if (at (a , x , y))
            {
                // ??????????????? -> A,C,E,G
                if (at (a , x + 1 , y))
                {
                    // ??????????????? -> A,G
                    if (at (a , x , y + 1))
                    {
                        // ??????????????????????????? -> A
                        if (at (a , x + 1 , y + 1))
                        {
                            return 'A';
                        }
                        // ??????????????????????????? -> G
                        else
                        {
                            return 'G';
                        }
                    }
                    // ??????????????? -> C,E
                    else
                    {
                        // 2??????????????? -> C
                        if (at (a , x + 2 , y))
                        {
                            return 'C';
                        }
                        // 2?????????????????? -> E
                        else
                        {
                            return 'E';
                        }
                    }
                }
                // ??????????????? -> B,D,F
                else
                {
                    // 2??????????????? -> B
                    if (at (a , x , y + 2))
                    {
                        return 'B';
                    }
                    // ???????????????????????? -> F
                    else if (at (a , x + 1 , y + 1))
                    {
                        return 'F';
                    }
                    // ???????????????
                    else
                    {
                        return 'D';
                    }
                }
                throw undefined;
            }
        }
    }
    return 'X';
}

auto main () -> int
{
    char a [8] [8];
    while (input (a))
    {
        std::cout << check (a) << std::endl;
    }
}