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)
		fmt.Scanln()
	}
}

C++: #include<stdio.h>
int memo[4][2]={0};
char n;
int cou;
int main()
{
    while(1)
    {
        cou=0;
        for(int i=0;i<8;i++)
        {
            for(int j=0;j<9;j++)
            {
                if(scanf("%c",&n)!=EOF)
                {
                    if(n!='0'&&n!='\n')
                    {
                        memo[cou][0]=i;
                        memo[cou][1]=j;
                        cou++;
                    }
                }
                else return 0;
            }
        }
        if(memo[0][0]==memo[1][0])//A,C,E,G
        {
            if(memo[1][1]==memo[2][1]||memo[0][1]==memo[3][1])//E,G
            {
                if(memo[1][1]==memo[2][1])printf("E\n");
                else printf("G\n");
            }
            else//A,C
            {
                if(memo[0][0]==memo[3][0])printf("C\n");
                else printf("A\n");
            }
        }
        else//B,D,F
        {
            if(memo[0][1]==memo[3][1])printf("B\n");
            else//D,F
            {
                if(memo[0][1]==memo[1][1])printf("F\n");
                else printf("D\n");
            }
        }
    }
}

C++: #include <stdio.h>
#include <string.h>

int main(void){
	char b[65];
	char p[7][33] = {
		"1100000011",
		"10000000100000001000000010000000",
		"1111",
		"1000000110000001",
		"11000000011",
		"100000001100000001",
		"110000011",
	};
	char *bi;

	while(true){
		for(int i=0; i<8; ++i){
			scanf("%s", b+i*8);
		}
		bi = strchr(b, '1');
		for(int i=0; i<7; ++i){
			if(memcmp(bi, p[i], strlen(p[i])) == 0){
				printf("%c\n", 'A' + i);
				break;
			}
		}

		if(scanf("%c", b) == EOF){ break; }
		if(scanf("%c", b) == EOF){ break; }
	}
	return 0;
}

C++: // A Figure on Surface
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

string str;
int i,xbase,ybase,ans;
void solve(){
	char ch;
	switch(ans){
		case 11:
			ch = 'A';
			break;
		case 0:
			ch = 'B';
			break;
		case 6:
			ch = 'C';
			break;
		case -110:
			ch = 'D';
			break;
		case 31:
			ch = 'E';
			break;
		case 110:
			ch = 'F';
			break;
		default:
			ch = 'G';
			break;
	}
	cout << endl << ans << endl;
	cout << ch << endl;
}
void init(){
	i = 0;
	xbase = ybase = -1;
	ans = 0;
}
int main(){
	while(cin >> str){
		for(int j=0;j<8;j++){
			if(str[j]=='1'){
				if(xbase == -1){
					xbase = j;
					ybase = i;
				} else {
					ans += (j-xbase)*pow(10,i-ybase);
				}
			}
		}
		i++;
		if(i==7){
			solve();
			init();
		}
	}
}

C++: #include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
 
int xb[7][3] = {
        {1, 0, 1},
        {0, 0, 0},
        {1, 2, 3},
        {0, -1, -1},
        {1, 1, 2},
        {0, 1, 1},
        {1, 0, -1}
};
 
int yb[7][3] = {
        {0, 1, 1},
        {1, 2, 3},
        {0, 0, 0},
        {1, 1, 2},
        {0, 1, 1},
        {1, 1, 2},
        {0, 1, 1}
};
 
int main() {
        string field[8];
        while(getline(cin, field[0])) {
                for(int i = 1; i < 8; i++) getline(cin, field[i]);
 
                char ans = '\0';
                rep(y,8) {
                        rep(x,8) {
                                if(field[y][x] == '1') {
                                        // cerr << "x: " << x << " " << "y: " << y << endl;
                                        rep(i,8) {
                                                bool f = true;
                                                rep(j,3) {
                                                        int nx = x + xb[i][j];
                                                        int ny = y + yb[i][j];
#if 1
                                                        if(0 <= nx && nx < 8 && 0 <= ny && ny < 8) {
                                                                if(field[ny][nx] != '1') {
                                                                        f = false;
                                                                        break;
                                                                }
                                                        }       
#endif
                                                }
                                                if(f) {
                                                        ans = 'A' + i;
                                                        goto END;
                                                }
                                        }
                                }
                        }
                }
        END:
                cout << ans << endl;
                getline(cin, field[0]);
        }
        return 0;
}

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

int main() {
  char x;
 NEXT:
  while(1) {
    if(cin.eof()) {goto END;}
    cin.get(x);
    if(x == '1') {
      break;
    }
  }
  cin.get(x);
  if(x == '1') {// A,C,E,G
    cin.get(x);
    if(x == '1') // C
      cout << "C" << endl;
    else if(x == '0') {//A,E,G
      for(int i=0;i<6;i++){
        cin.get(x);
      }
      if(x == '1')
        cout << "G" << endl; // G
      else if(x == '0') {
        cin.get(x);
        if(x == '1')
          cout << "A" << endl; // A
        else
          cout << "E" << endl; // E
      }
    }
  }
  else if(x == '0') {//B,D,F
    for(int i=0;i<6;i++) {
      cin.get(x);
    }
    if(x == '1')
      cout << "D" << endl;
    else if(x == '0') {
      cin.get(x);
      cin.get(x);
      if(x == '1')
        cout << "F" << endl;
      else
        cout << "B" << endl;
    }
  }
  while(1){
    cin.get(x);
      if(x == '\n') {
        cin.get(x);
        if(x == '\n')
          goto NEXT;
      }
  }
 END:
  return 0;
}