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 <bits/stdc++.h>

using namespace std;

char mp[8][9];

int A[4][2] = {{0, 0}, {0, 1}, {1, 0}, {1, 1}};
int B[4][2] = {{0, 0}, {1, 0}, {2, 0}, {3, 0}};
int C[4][2] = {{0, 0}, {0, 1}, {0, 2}, {0, 3}};
int D[4][2] = {{0, 1}, {1, 0}, {1, 1}, {2, 0}};
int E[4][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 2}};
int F[4][2] = {{0, 0}, {1, 0}, {1, 1}, {2, 1}};
int G[4][2] = {{1, 0}, {1, 1}, {0, 1}, {0, 2}};

int main()
{
	int nyan = 0;
	while (1) {
		int i = 0;
		while (1) {
			int res = scanf("%s", mp[i++]);
			if (res == EOF) return 0;
			if (i == 8) break;
		}

		int cnt;

		for (int i = 0; i < 8; ++i) for (int j = 0; j < 8; ++j) {
			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + A[k][0], nx = j + A[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("A");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + B[k][0], nx = j + B[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("B");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + C[k][0], nx = j + C[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("C");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + D[k][0], nx = j + D[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("D");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + E[k][0], nx = j + E[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("E");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + F[k][0], nx = j + F[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("F");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + G[k][0], nx = j + G[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("G");
				continue;
			}
		}
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  vector<string> s(16);
  for(int i=0; i<4; i++) s[i] = "0000000000000000";
  for(int i=12; i<16; i++) s[i] = "0000000000000000";
  while(cin >> s[4]){
    for(int i=5; i<12; i++) cin >> s[i];
    for(int i=4; i<12; i++) s[i] = "0000" + s[i] + "0000";

    bool f = false;
    for(int i=4; i<12; i++){
      for(int j=4; j<12; j++){
        if( f ) continue;
        if( s[i][j] == '0' ) continue;

        if( s[i][j] == '1' && s[i+1][j] == '1' && s[i][j+1] == '1' && s[i+1][j+1] == '1' ) cout << 'A' << endl;
        else if( s[i][j] == '1' && s[i+1][j] == '1' && s[i+2][j] == '1' && s[i+3][j] == '1' ) cout << 'B' << endl;
        else if( s[i][j] == '1' && s[i][j+1] == '1' && s[i][j+2] == '1' && s[i][j+3] == '1' ) cout << 'C' << endl;
        else if( s[i][j] == '1' && s[i+1][j] == '1' && s[i+1][j-1] == '1' && s[i+2][j-1] == '1' ) cout << 'D' << endl;
        else if( s[i][j] == '1' && s[i][j+1] == '1' && s[i+1][j+1] == '1' && s[i+1][j+2] == '1' ) cout << 'E' << endl;
        else if( s[i][j] == '1' && s[i+1][j] == '1' && s[i+1][j+1] == '1' && s[i+2][j+1] == '1' ) cout << 'F' << endl;
        else if( s[i][j] == '1' && s[i][j+1] == '1' && s[i+1][j] == '1' && s[i+1][j-1] == '1' ) cout << 'G' << endl;

        f = true;
      }
    }


  }

  return 0;
}

// EOF

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

string s[10];

int main() {
	int t = 0;
	int r = 0;
	for (int i = 0; i < 9; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < 9; i++) {
		for (int j = 0; j < 9;j++)
		{
			if (s[i][j] == '1') {
				if (t == 0)t = j;
				r += j;
			}
		}
	}
	r -= 4*t;
	if (r == 19)cout << 'A' << endl;
	else if (r == 48)cout << 'B' << endl;
	else if (r == 6)cout << 'C' << endl;
	else if (r == 30)cout << 'D' << endl;
	else if (r == 20)cout << 'E' << endl;
	else if (r == 34)cout << 'F' << endl;
	else if (r == 16)cout << 'G' << endl;
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 8;

int main(void){
    for(vs t(N);;){
        int l = N, r = 0, u = N, d = 0;
        rep(i, N){
            if(!(cin >> t[i])) return 0;
            
            rep(j, N) if(t[i][j] == '1')
                l = min(l, j), r = max(r, j), 
                u = min(u, i), d = max(d, i);
        }
        int w = r - l + 1, h = d - u + 1;

        cout << (w == 4 ? 'C':h == 4 ? 'B':w == 2 ? h == 2 ? 'A': t[u][l] ? 'F':'D': t[u][l] ? 'E':'G') << endl;
    }
 
    return 0;
}