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++: import java.util.Scanner;

public class Main {

	static Scanner sc = new java.util.Scanner(System.in);

	// static int[][] num =new int [8][8];

	public static void main(String[] args) {

		int[][] num = new int[15][15];
		String str = "";

		while (sc.hasNextLine()) {
			// num[][]????????????
			syokika(num);
			// ???????????¨????????????????´?
			for (int i = 0; i < 8; i++) {
				str = sc.next();
				String[] st = str.split("");
				for (int j = 0; j < 8; j++) {
					num[i][j] = Integer.parseInt(st[j]);
				}
			}
			// ????????????
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 8; j++) {
					if (num[i][j] == 1 && num[i][j + 1] == 1 && num[i + 1][j] == 1 && num[i + 1][j + 1] == 1) {
						System.out.println("A");
					} else if (num[i][j] == 1 && num[i + 1][j] == 1 && num[i + 2][j] == 1 && num[i + 3][j] == 1) {
						System.out.println("B");
					} else if (num[i][j] == 1 && num[i][j + 1] == 1 && num[i][j + 2] == 1 && num[i][j + 3] == 1) {
						System.out.println("C");
					} else if (num[i][j + 1] == 1 && num[i + 1][j] == 1 && num[i][j + 1] == 1 && num[i + 2][j] == 1) {
						System.out.println("D");
					} else if (num[i][j] == 1 && num[i][j + 1] == 1 && num[i + 1][j + 1] == 1
							&& num[i + 1][j + 2] == 1) {
						System.out.println("E");
					} else if (num[i][j] == 1 && num[i + 1][j] == 1 && num[i + 1][j + 1] == 1
							&& num[i + 2][j + 1] == 1) {
						System.out.println("F");
					} else if (num[i][j + 1] == 1 && num[i][j + 2] == 1 && num[i + 1][j] == 1
							&& num[i + 1][j + 1] == 1) {
						System.out.println("B");
					}

				}
			}

		}

	}

	// ???????????¢??°
	public static int[][] syokika(int[][] num) {

		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				num[i][j] = 0;
			}
		}
		return num;
	}

}

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

int main(){
	int mass[8][8];
	
	BEGIN:
	while(scanf("%d%d%d%d%d%d%d%d",(*mass[0]),(*mass[0])+1,(*mass[0])+2,(*mass[0])+3,(*mass[0])+4
		(*mass[0])+5,(*mass[0])+6,(*mass[0])+7)!=EOF)
	{
		for(int i=1;i<8;i++){
			scanf("%d%d%d%d%d%d%d%d",(*mass[i]),(*mass[i]+1),(*mass[i]+2),(*mass[i]+3),(*mass[i]+4)
				(*mass[i]+5),(*mass[i]+6),(*mass[i]+7));
		}
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(mass[i][j]){
					if(j==7){
						if(mass[i+1][j]){
							cout<<(mass[i+1][j-1]?"D\n":"B\n");
						}
					}else if(j==0){
						if(mass[i][j+1]){
							if(mass[i+1][j]) cout<<"A\n";
							else if(mass[i][j+2]) cout<<"C\n";
							else cout<<"E\n";
						}
						else cout<<(mass[i+1][j+1]?"F\n":"B\n");
					}else{
						if(mass[i][j+2]) cout<<"C\n";
						else if(mass[i][j+1]){
							if(mass[i+1][j]){
								cout<<(mass[i+1][j+1]?"A\n":"G\n");
							}
							else cout<<"E\n";
						}
						else if(mass[i+2][j]) cout<<"B\n";
						else cout<<(mass[i+1][j+1]?"F\n":"D\n");
					}
					goto BEGIN;
				}
			}
		}
	}
}

C++: #include <cstdio>
#include <utility>
#include <vector>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
is(string &s){int c; s = "";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

typedef vector<string> v;

char pat_search(v &a) {
	static auto p = [&a](int i, int j) {
		return i >= 0 && i < 8 && j >= 0 && j < 8 && a[i][j] == '1';};
	for (int i = 0; i < 8; i++)
		for (int j = 0; j < 8; j++)
			if (a[i][j] == '1') {
				return p(i + 1, j + 1) ? p(i, j + 1) ? p(i + 1, j + 2) ? 'E' : 'A' : 'F' :
					p(i, j + 1) ? p(i, j + 2) ? 'C' : 'D' :
					p(i + 2, j) ? 'B' : 'E';
			}
	return 'X';
}

int main() {
	v a(8);
	do {
		for (auto &s: a)
			scan(s);
		out(pat_search(a), '\n');
	} while (gcu() == '\n');
}

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

int main(){
  bool bmap[10][10];
  string s;
  for(int i=1;i<=8;i++){
    cin >> s;
    for(int j=0;j<s.length();j++){
      if(s[j] == '0')bmap[i][j+1] = false;
      else bmap[i][j+1] = true;
    }
  }
  for(int i=1;i<=8;i++){
    for(int j=1;j<=8;j++){
      if(bmap[i][j]){
	if(j+1<= 8 && i+1<=8 &&bmap[i][j+1] && bmap[i+1][j] && bmap[i+1][j+1]){
	  cout << "A" << endl; break;
	}
	else if(i+3<=8 && bmap[i+1][j] && bmap[i+2][j] && bmap[i+3][j]){
	  cout << "B" << endl; break;
	}
	else if(j+3<=8 && bmap[i][j+1] && bmap[i][j+2] && bmap[i][j+3]){
	  cout << "C" << endl; break;
	}
	else if(i+2<=8 && 1<=j-1 && bmap[i+1][j] && bmap[i+1][j-1] && bmap[i+2][j-1]){
	  cout << "D" << endl; break;
	}
	else if(i+1<=8 && j+2<=8 && bmap[i][j+1] && bmap[i+1][j+1] && bmap[i+1][j+2]){
	  cout << "E" << endl; break;
	}
	else if(i+2<=8 && j+1<=8 && bmap[i+1][j] && bmap[i+1][j+1] && bmap[i+2][j+1]){
	  cout << "F" << endl; break;
	}
	else if(i+1<=8 && 1<=j-1 && j+1<=8 && bmap[i][j+1] && bmap[i+1][j] && bmap[i+1][j-1]){
	  cout << "G" << endl; break;
	}
      }
    }
  }
  return 0;
}