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<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
int main(void){
  char maze[9][9];
  while(true){
    rep(i,8)rep(j,8)cin>>maze[i][j];
    if(cin.eof())break;
    bool used = false;
    rep(y,8){
      rep(x,8){
	if (board[y][x] == '1') {
	  if (board[y][x+1] == '1' && board[y+1][x] == '1' && board[y+1][x+1] == '1')
	    cout << "A" << endl;
	  else if (board[y+1][x] == '1' && board[y+2][x] == '1' && board[y+3][x] == '1')
	    cout << "B" << endl;
	  else if (board[y][x+1] == '1' && board[y][x+2] == '1' && board[y][x+3] == '1')
	    cout << "C" << endl;
	  else if (board[y+1][x] == '1' && board[y+1][x-1] == '1' && board[y+2][x-1] == '1')
	    cout << "D" << endl;
	  else if (board[y][x+1] == '1' && board[y+1][x+1] == '1' && board[y+1][x+2] == '1')
	    cout << "E" << endl;
	  else if (board[y+1][x] == '1' && board[y+1][x+1] == '1' && board[y+2][x+1] == '1')
	    cout << "F" << endl;
	  else
	    cout << "G" << endl;
	  used = true;
	}
	/*
	  if(maze[y][x]=='1'){
	  if(maze[ y ][x+1] == '1' && maze[y+1][ x ] =='1' &&
	  maze[y+1][x+1] =='1') cout << "A" << endl;
	  else if(maze[y+1][ x ] == '1' && maze[y+2][ x ] == '1' &&
	  maze[y+3][ x ] == '1') cout << "B" << endl;
	  else if(maze[ y ][x+3] == '1' && maze[y][x+2] == '1' &&
	  maze[ y ][x+1] == '1') cout << "C" << endl;
	  else if(maze[y+1][ x ] == '1' && maze[y+1][x-1] == '1' &&
	  maze[y+2][x-1] == '1') cout << "D" << endl;
	  else if(maze[ y ][x+1] == '1' && maze[y+1][x+1] == '1' &&
	  maze[y+1][x+2] == '1') cout << "E" << endl;
	  else if(maze[y+1][ x ] == '1' && maze[y+1][+1] == '1' &&
	  maze[y+2][x+1] == '1') cout << "F" << endl;
	  else cout << "G" << endl;
	  used = true;
	  }
	*/
	if(used)break;
      }
      if(used)break;
    }
  }

  return 0;
}

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