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 < 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>
#include <vector>
#include <string>
using namespace std;

int main(){
    while(1){
        vector<string> v(8);
        int sx=8,sy=8,ex=-1,ey=-1;
        for(int i=0; i<8; i++){
            if(!(cin>>v[i])) goto end;
            for(int j=0; j<8; j++){
                if(v[i][j]=='1'){
                    sx=min(sx,j);
                    sy=min(sy,i);
                    ex=max(ex,j);
                    ey=max(ey,i);
                }
            }
        }
        char ans;
        if(sx==ex) ans='B';
        else if(sy==ey) ans='C';
        else if(ex-sx==1&&ey-sy==1) ans='A';
        else if(v[ey][ex]=='0'&&sx-ex==1) ans='G';
        else if(v[ey][ey]=='0'&&sx-ey==2) ans='D';
        else if(ex-sx==2) ans='E';
        else ans='F';
        cout<<ans<<endl;
    }
 end:;
}

C++: #include<iostream>
#include<string>
#include<vector>
#define N 8

using namespace std;

int checkA(const vector<string>, int, int);
int checkB(const vector<string>, int, int);
int checkC(const vector<string>, int, int);
int checkD(const vector<string>, int, int);
int checkE(const vector<string>, int, int);
int checkF(const vector<string>, int, int);
int checkG(const vector<string>, int, int);

int main(){
  int i, j, isFound;
  string s;
  vector<string> data;

  while(cin >> s){
    data.push_back(s);

    for(i=1; i<N; ++i){
      cin >> s;
      data.push_back(s);
    }

    for(i=0, isFound=0; i<N; ++i){
      for(j=0; j<N; ++j){
        if(data[i][j] == '1'){
	  isFound = 1;
          break;
        }
      }
      if(isFound == 1) break;
    }

    if(checkA(data, i, j) == 1) cout << "A" << endl;
    else if(checkB(data, i, j) == 1) cout << "B" << endl;
    else if(checkC(data, i, j) == 1) cout << "C" << endl;
    else if(checkD(data, i, j) == 1) cout << "D" << endl;
    else if(checkE(data, i, j) == 1) cout << "E" << endl;
    else if(checkF(data, i, j) == 1) cout << "F" << endl;
    else if(checkG(data, i, j) == 1) cout << "G" << endl;

    data.clear();
  }

  return 0;
}

int checkA(const vector<string> data, int i, int j){
  int n, m;
  n = i + 1;
  m = j + 1;
  if(n < N && m < N){
    if(data[i][m] == '1' && data[n][j] == '1' && data[n][m] == '1')
      return 1;
  }
  return 0;
}

int checkB(const vector<string> data, int i, int j){
  int n;
  n = i + 3;

  if(n < N){
    if(data[i+1][j] == '1' && data[i+2][j] == '1' && data[n][j] == '1')
      return 1;
  }
  return 0;
}

int checkC(const vector<string> data, int i, int j){
  int n, m;
  n = j + 3;

  if(n < N){
    if(data[i][j+1] == '1' && data[i][j+2] == '1' && data[i][n] == '1')
      return 1;
  }
  return 0;
}

int checkD(const vector<string> data, int i, int j){
  int n, m;
  n = i + 2;
  m = j - 1;

  if(n < N && m >= 0){
    if(data[i+1][m] == '1' && data[i+1][j] == '1' && data[n][m] == '1')
      return 1;
  }
  return 0;
}

int checkE(const vector<string> data, int i, int j){
  int n, m;
  n = i + 1;
  m = j + 2;

  if(n < N && m < N){
    if(data[i][j+1] == '1' && data[n][j+1] == '1' && data[n][m] == '1')
      return 1;
  }
  return 0;
}

int checkF(const vector<string> data, int i, int j){
  int n, m;
  n = i + 2;
  m = j + 1;

  if(n < N && m < N){
    if(data[i+1][j] == '1' && data[i+1][m] == '1' && data[n][m] == '1')
      return 1;
  }
  return 0;
}

int checkG(const vector<string> data, int i, int j){
  int k, n, m;
  k = j - 1;
  n = i + 1;
  m = j + 1;

  if(k >= 0 && n < N && m < N){
    if(data[i][m] == '1' && data[n][k] == '1' && data[n][j] == '1')
      return 1;
  }
  return 0;
}

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;
}