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 < 8; i++ {
			for j := 0; j < 8; 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 < 8; 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 < 8; 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 < 8; i++ {
			for j := 0; j < 8; 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 < 8; i++ {
			for j := 0; j < 8; 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 < 8; i++ {
			for j := 0; j < 8; 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 < 8; i++ {
			for j := 0; j < 8; 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()
{
	while(!cin.eof())
	{
		if(cin.eof())
			break;
		long a[8] = {0};
		for(int i = 0; i < 8; i++)
		{
			long x;
			cin >> x;
			for(int j = 0; j < 8; j++)
			{
				a[i] += (x % 10) << j;
				x /= 10;
			}
		}

		/*for(int i = 0; i < 8; i++)
			cout << i << ' ' << a[i] << endl;
		*/

		char c = 'A';
		for(int i = 0; i < 7; i++)
			for(int j = 0; j < 7; j++)
				if(a[i] == 3 << j)
					if(a[i + 1] == 3 << j)
						goto END;

		c = 'B';
		for(int i = 0; i < 5; i++)
			for(int j = 0; j < 8; j++)
				if(a[i] == (1 << j))
					if(a[i + 1] == (1 << j))
					{
						//cout << "B " << (1 << j) << endl;
						goto END;
					}

		c = 'C';
		for(int i = 0; i < 8; i++)
			for(int j = 0; j < 5; j++)
			{
				//cout << 'C' << ' ' << (15 << j) << endl;
				if(a[i] == 15 << j)
					goto END;

			}
		c = 'D';
		for(int i = 0; i < 6; i++)
			for(int j = 0; j < 7; j++)
				if(a[i] == 1 << j)
					if(a[i + 1] == 3 << j)
						goto END;

		c = 'E';
		for(int i = 0; i < 7; i++)
			for(int j = 0; j < 7; j++)
				if(a[i] == 3 << j)
					if(a[i + 1] == 3 << (j-1))
						goto END;

		c = 'F';
		for(int i = 0; i < 6; i++)
			for(int j = 0; j < 8; j++)
				if(a[i] == 1 << j)
					goto END;

		c = 'G';
		for(int i = 0; i < 7; i++)
			for(int j = 0; j < 6; j++)
				if(a[i] == 1 << j)
					if(a[i + 1] == 1 << (j + 1))
						goto END;

		break;

	END:
		cout << c << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	char c[10][10];
    while (cin>>c[0][0]){
        for (int i = 0; i < 8; i++)
            for (int j = 0; j < 8; j++)
                if(!i&&!j)continue;
                cin >> c[i][j];
        int a, b;
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                if (c[i][j] == '1') {
                    a = i;
                    b = j;
                    goto C;
                }
            }
        }
    C:
        if (c[a][b + 1] == '1') {
            if (c[a + 1][b] == '1') {
                if (c[a + 1][b + 1] == '1')
                    cout << 'A';
                else cout << 'G';
            }
            else {
                if (c[a + 1][b + 1] == '1')
                    cout << 'E';
                else cout << 'C';
            }
        }
        else if (c[a + 1][b + 1] == '1')
            cout << 'F';
        else if (c[a + 1][b - 1] == '1')
            cout << 'D';
        else cout << 'B';
        cout << endl;
    }
    return 0;
}

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 = 8*i+j;
				r += 8*i+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>
using namespace std;

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  string buf;
  string code="...B.AD..E..C";
  int brd[8][8];
  char ans;
  
  while (cin>>buf){
    int l=8,r=-1,t=8,b=-1, w, h;
    for (int i=0; i<8; i++){
      brd[i][0] = buf[i]-'0';
      if (brd[i][0]==1){
        l = MIN(i,l); r = MAX(i,r);
        t = MIN(0,t); b = MAX(0,b);
      }
    }
    for (int j=1; j<8; j++){
      cin >> buf;
      for (int i=0; i<8; i++){
        brd[i][j] = buf[i]-'0';
        if (brd[i][j]==1){
          l = MIN(i,l); r = MAX(i,r);
          t = MIN(j,t); b = MAX(j,b);
        }
      }
    }
    w = r-l+1; h = b-t+1;
    ans = code[((w-1)<<2)|(h-1)];
    if (ans=='D' && brd[l][t]==1) ans = 'F';
    if (ans=='E' && brd[l][t]==0) ans = 'G';
//    cout << l << " " << r << " " << t << " " << b << " ";
//    cout << w << " " << h << " ";
    cout << ans << endl;
  }

  return 0;
}

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

int main()
{
	int s[8], count, f;
	while(cin >> s[0]){
		count = 0;
		for (int i = 1; i < 8; i++){
			cin >> s[i];
		}

		for (int i = 0; i < 8; i++){
			if (s[i] > 0) count++;
		}
	
		if (count == 4) cout << "B" << endl;
		else if (count == 1) cout << "C" << endl;
		else if (count == 3) {
			for (int i = 0; i < 8; i++){
				if (s[i] > 0){
					if (s[i] < s[i + 2]) cout << "D" << endl;
					else cout << "F" << endl;
					i = 9;
				}
			}
		}
		else if (count == 2){
			for (int i = 0; i < 8; i++){
				if (s[i] > 0){
					if (s[i] == s[i + 1]) cout << "A" << endl;
					else if (s[i] > s[i + 1]) cout << "E" << endl;
					else cout << "G" << endl;
					i = 9;
				}
			}
		}
	}
	return (0);
}