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>
#include<cstdio>

using namespace std;

int A[7][4][4]={
  
  {
    {1,1,0,0},
    {1,1,0,0},
    {0,0,0,0},
    {0,0,0,0},
  },
  
  {
    {1,0,0,0},
    {1,0,0,0},
    {1,0,0,0},
    {1,0,0,0},
  },
  
  {
    {1,1,1,1},
    {0,0,0,0},
    {0,0,0,0},
    {0,0,0,0},
  },
  
  {
    {0,1,0,0},
    {1,1,0,0},
    {1,0,0,0},
    {0,0,0,0},
  },
  
  {
    {1,1,0,0},
    {0,1,1,0},
    {0,0,0,0},
    {0,0,0,0},
  },
  
  {
    {1,0,0,0},
    {1,1,0,0},
    {0,1,0,0},
    {0,0,0,0},
  },
  
  {
    {0,1,1,0},
    {1,1,0,0},
    {0,0,0,0},
    {0,0,0,0},
  },
},
  
  a[12][12];

string s="ABCDEFG";

void check(){


  for(int n=0;n<7;n++){

    for(int i=0;i<7;i++){
      for(int j=0;j<7;j++){

	bool fg=true;
	for(int k=0;k<4;k++){
	  for(int l=0;l<4;l++){
	    if(a[i+k][j+l]!=A[n][k][l]){
	      fg=false;
	      break;
	    }
	    if(i+k<0||i+k>7||j+l<0||j+k>7){
	      fg=false;
	      break;
	    }
	  }
	  if(!fg)break;
	}
	if(fg){
	  cout << s[n] << endl;
	  return;
	}
	fg=true;
	
      }
    }
  }

}


int main(void){

  char ch;

  while(true){

    for(int i=0;i<12;i++)
      for(int j=0;j<12;j++)
	a[i][j]=0;
    
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	if(scanf(" %c",&ch)==EOF)return 0;
	a[i][j]=ch-'0';
      }
    }
    check();
  }

  return 0;
}

C++: #include <bits/stdc++.h>

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int a[100];

void solve()
{
  int b;
  REP(i,64) if(a[i])
  {
    b = i;
    break;
  }
  if(a[b+1])
  {
    if(a[b+2]) printf("C\n");
    else if(a[b+8])
    {
      if(a[b+9]) printf("A\n");
      else printf("G\n");
    }
    else printf("E\n");
  }
  else if(a[b+16]) printf("B\n");
  else if(a[b+9]) printf("F\n");
  else printf("D\n");
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int i = 0; string s;
  fill_n(a,100,0);
  while(cin >> s)
  {
    REP(j,8) a[i*8+j] = (s[j]-'0');
    (++i) %= 8;
    if(i == 0) solve();
  }
  return 0;
}

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