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++: #include<iostream>
using namespace std;

int main() {
	char c[8][8];
	while (cin >> c[0]) {
		for (int i = 1;i < 8;i++)cin >> c[i];

		int ax, ay;
		for (int i = 0;i < 8;i++) {
			for (int j = 0;j < 8;j++) {
				if (c[i][j] == '1') {
					ax = i;
					ay = j;
					goto floop;
				}
			}
		}
	floop:
		if (c[ax][ay] == c[ax][ay + 1]) {
			if (ax<7&&c[ax][ay] == c[ax + 1][ay] && c[ax][ay] == c[ax + 1][ay+1])cout << 'A' << endl;
			else if (ay<5&&c[ax][ay] == c[ax][ay + 2] && c[ax][ay ] == c[ax][ay + 3])cout << 'C' << endl;
			else if (ax<7&&ay<6&&c[ax][ay] == c[ax + 1][ay + 1] && c[ax][ay] == c[ax + 1][ay + 2])cout << 'E' << endl;
			else if (ay > 1 && c[ax][ay] == c[ax + 1][ay] && c[ax][ay] == c[ax + 1][ay - 1])cout << 'G' << endl;
		}
		if (c[ax][ay] == c[ax + 1][ay]) {
			if (ax<5&&c[ax][ay] == c[ax + 2][ay] && c[ax][ay] == c[ax + 3][ay])cout << 'B' << endl;
			else if (ax<6&&ay<7&&c[ax][ay] == c[ax + 1][ay + 1] && c[ax][ay] == c[ax + 2][ay + 1])cout << 'F' << endl;
			else if(c[ax+1][ay+1]=='0'&&c[ax+2][ay]=='1')cout << 'D' << endl;
		}
	}
	return 0;
}

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

void solve(vector<string> p) {
  char c;
  for (int i=0;i<8;i++)
  for (int j=0;j<8;j++)
  if (p[i][j]=='1') {
    if (p[i][j+1]=='1' && p[i+1][j]=='1' && p[i+1][j+1]=='1') c='A';
    else if (p[i+1][j]=='1' && p[i+2][j]=='1' && p[i+2][j]=='1') c='B';
    else if (p[i][j+1]=='1' && p[i][j+2]=='1' && p[i][j+3]=='1') c='C';
    else if (p[i+1][j]=='1' && p[i+1][j-1]=='1' && p[i+2][j-1]=='1') c='D';
    else if (p[i][j+1]=='1' && p[i+1][j+1]=='1' && p[i+1][j+2]=='1') c='E';
    else if (p[i+1][j]=='1' && p[i+1][j+1]=='1' && p[i+2][j+1]=='1') c='F';
    else if (p[i][j+1]=='1' && p[i+1][j]=='1' && p[i+1][j-1]=='1') c='G';
    cout<<c<<endl;
    return;
  }
}

int main(int argc, char const* argv[]) {
  string empty;
  while (true) {
    vector<string> plane(14);
    for (int i=0;i<8;i++) getline(cin, plane[i]);
    for (int i=0;i<8;i++) plane[i]+="000000";
    for (int i=8;i<14;i++) plane[i]="00000000000000";
    
    solve(plane);
    
    if (!getline(cin, empty)) break;
  }
  return 0;
}

C++: //A Figure on Surface

#include<iostream>
#include<string>
using namespace std;

int main(void)
{
	const int N = 8;
	while(1)
	{
		string a[N];
		int i, j;
		for(i = 0; i < N; i++)
		{
			cin >> a[i];
		}
		if(!cin)
			break;

		//¶ã©çÌÀWð²×é
		for(i = 0; i < N; i++)
		{
			for(j = 0; j < N; j++)
			{
				if(a[i][j] == '1')
					goto DISCOVER;
			}
		}
		DISCOVER:
		//ÔÈñÄÇ¤ÅàÇ¢©çÀSÉs«Üµå¤
		if( (a[i][j] == a[i+1][j]) &&
			(a[i][j] == a[i][j+1]) &&
			(a[i][j] == a[i+1][j+1]) )
			cout << 'A' << endl;
		else if((i < N-3) && 
			(a[i][j] == a[i+3][j]) )
			cout << 'B' << endl;
		else if((j < N-3) &&
			(a[i][j] == a[i][j+3]) )
			cout << 'C' << endl;
		else if((i < N-2) && (j > 0 ) &&
			(a[i][j] == a[i+2][j-1]) )
			cout << 'D' << endl;
		else if((j < N-2) &&
			(a[i][j] == a[i+1][j+2]) )
			cout << 'E' << endl;
		else if((i < N-2) &&
			(a[i][j] == a[i+2][j+1]) )
			cout << 'F' << endl;
		else
			cout << 'G' << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
string match(const vector<string> v){
	const string PTN[7][4]{
		{"11","11"},
		{"1","1","1","1"},
		{"1111"},
		{"01","11","10"},
		{"110","011"},
		{"10","11","01"},
		{"011","110"}
	};
	const int PTN_H[7]{2,4,1,3,2,3,2};
	const string PTN_NAME[7]={"A","B","C","D","E","F","G"};
	int ans=-1;
	for(int k=0;k<7;++k){
		int pw=PTN[k][0].size(),ph=PTN_H[k];
		for(int i=0;i<8;++i){
			for(int j=0;j<8;++j){
				if(i+ph<=8&&j+pw<=8){
					bool f=true;
					for(int l=0;l<ph;++l){
						if(PTN[k][l]!=v[i+l].substr(j,pw))f=false;
					}
					if(f){ans=k;break;break;break;}
				}else{
					break;
				}
			}
		}
	}
	return PTN_NAME[ans];
}
int main(){
	for(;;){
		vector<string> surface;
		for(int i=0;i<8;++i){
			string s;
			cin>>s;
			if(s.empty())return 0;
			surface.push_back(s);
		}
		string ans = match(surface);
		cout<<ans<<endl;
		if(cin.eof())break;
	}
	return 0;
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  string tmp;
  string s[8];
  unordered_map<int, string> mp;
  mp[18] = "A";
  mp[48] = "B";
  mp[6] = "C";
  mp[30] = "D";
  mp[20] = "E";
  mp[34] = "F";
  mp[16] = "G";
  do{
    rep(i, 8){
      if(!getline(cin, s[i])){
        return 0;
      }
    }
    int at = -1;
    int sum = 0;
    rep(i, 8){
      rep(j, 8){
        if(s[i][j] == '1'){
          if(at == -1){
            at = i * 8 + j;
          }else{
            sum += i * 8 + j - at;
          }
        }
      }
    }
    cout << mp[sum] << endl;
  }while(getline(cin, tmp));
	return 0;
}