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.io.IOException;

public class Main {
	

	public static void main(String[] args) {
		try {
			final int SIZE = 20 + 10 * 8 * ((8 + 4) * 8);// 8桁＋終端　を　8行に＋空行を10回
			byte[] buf = new byte[SIZE];// 入力データをすべて格納する
			int count = 0;// 文字の先頭からの順番
			int limit = System.in.read(buf, 0, SIZE);

			while (count < limit) {
				int box[] = new int[4];
				int i = 0;
				int head = 0;
				int[] x = new int[4];
				while (count < limit) {
					if (buf[count] == '1') {
						box[i] = count;
						x[i] = head;
						i++;
						
					}
					if (buf[count] != '0' && buf[count] != '1')
						head = 0;
					else
						head++;
					count++;
					if(i > 3) break;
				}
				
				if(i != 4 ) break;
				
				if (box[0] == box[1] - 1) {
					// ACEG
					switch (x[2] - x[0]) {
					case -1:
						System.out.println("G");
						break;
					case 0:
						System.out.println("A");
						break;
					case 1:
						System.out.println("E");
						break;
					case 2:
						System.out.println("C");
						break;
					}
				} else {
					// BDF
					switch (x[3] - x[0]) {
					case -1:
						System.out.println("D");
						break;
					case 0:
						System.out.println("B");
						break;
					case 1:
						System.out.println("F");
						break;
					}
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

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

struct ca {
	int x;
	int y;
};

int main() {
	ca l[4];
	char c;
	while (true){
		int a = 0;
		for (int i = 0; i < 8; i++) {
			for (int j = 1; j < 8; j++) {
				cin >> c;
				if (c == '1')
				{
					l[a].x = i;
					l[a].y = j;
					a++;
				}
			}
		}
		int x = l[0].x;
		int y = l[0].y;
		if (l[1].x == x&&l[1].y == y + 1) {
			//[l0][l1]
			//ACEG
			if (l[3].x == x + 1 && l[3].y == y + 1)
				cout << 'A';
			else if (l[3].y == y + 3)
				cout << 'C';
			else if (l[3].x == x + 1 && l[3].y == y + 2)
				cout << 'E';
			else cout << 'G';
		}
		else if (l[1].x == x + 1 && l[1].y == y) {
			/*[l0]
			  [l1]*/
			  //BF
			if (l[3].x == x + 3 && l[3].y == y)
				cout << 'B';
			else cout << 'F';
		}
		else cout << 'D';
		cout << endl;
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
char a[8][8];
int ans = 0;
while(1){
for(int i = 0; i < 8; i++){
if(scanf("%s",&a[i]) == EOF){
return 0;
}
}

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

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

if(a[i][j] == 1){

if(i < 7 && j < 7){
if(a[i+1][j] == 1 && a[i][j+1] == 1 && a[i+1][j+1] == 1){
printf("A\n");
}
}
if(i < 5){
if(a[i+1][j] == 1 && a[i+2][j] == 1 && a[i+3][j] == 1){
printf("B\n");
}
}
if(j < 5){
if(a[i][j+1] == 1 && a[i][j+2] == 1 && a[i][j+3] == 1){
printf("C\n");
}
}
if(i < 6 && j < 5){
if(a[i][j+1] == 1 && a[i+1][j+1] == 1 && a[i+1][j+2] == 1){
printf("E\n");
}
}
if(i < 5 && j < 6){
if(a[i+1][j] == 1 && a[i+1][j+1] == 1 && a[i+2][j+1] == 1){
printf("F\n");
}
}
if(j > 0 && i < 6){
if(a[i+1][j] == 1 && a[i+1][j-1] == 1 && a[i+2][j-1] == 1){
printf("D\n");
}
}
if(j > 0 && j < 7 && i < 7){
if(a[i+1][j] == 1 && a[i][j+1] == 1 && a[i+1][j-1] == 1){
printf("G\n");
}
}

}

}

}

}

return 0;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
char board1[15][15];
int board[15][15];
int x ;
int main()
{
  bool flag1 = false;
  while( 1 ){
    for(int i=0 ; i<8; i++) {
      if(scanf("%s", board1[i]) == EOF ){
	flag1 = true;
	break;
      }
    }
    for(int i = 0;i < 8;i++){
      for(int j = 0;j <8;j++){
	board[i][j] =board1[i][j]-'0';
      }
    }
    if(flag1)
      break;
    bool flag = false;
    for(int i = 0;i < 8;i++){
      for(int j = 0;j < 8;j++){
	if(board[i][j] ==1){
	  if(board[i][j+1]==1&&board[i+1][j] ==1&&board[i+1][j+1]==1){
	    cout <<"A"<<endl;
	    flag = true;
	  }else if(board[i+1][j]==1&&board[i+2][j]==1&&board[i+3][j]==1){
	    cout <<"B"<<endl;
	    flag = true;
	  }else if(board[i][j+1]==1&&board[i][j+2]==1&&board[i][j+3]==1){
	    cout <<"C"<<endl;
	    flag = true;
	  }else if(board[i+1][j-1]==1&&board[i+1][j]==1&&board[i+1][j]==1&&board[i+2][j-1]==1){
	    cout <<"D"<<endl;
	    flag = true;
	  }else if(board[i][j+1]==1&&board[i+1][j+1]==1&&board[i+1][j+2]==1){
	    cout <<"E"<<endl;
	    flag = true;
	  }else if(board[i+1][j]==1&&board[i+1][j+1]==1&&board[i+2][j+1]==1){
	    cout <<"F"<<endl;
	    flag = true;
	  }else if(board[i][j+1] ==1&&board[i+1][j-1] ==1&&board[i+1][j]==1){
	    cout <<"G"<<endl;
	    flag = true;
	  }
	}
 
      }

    }
  
  }
  return 0;
}