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>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;

 char arr[8][8];
 
 int main()
 {
   while(cin>>arr[0][0])
   {
     int x[4],y[4];
     int cnt1,cnt2;
     cnt1=cnt2=0;
     if(arr[0][0]=='1') 
     {
       x[cnt1++]=0;
       y[cnt2++]=0;                   
     }
     for(int i=0;i<8;i++)
     {
       for(int j=0;j<8;j++)
       {
           if(i==0&&j==0) continue;
           else
           {
             cin>>arr[i][j];
             if(arr[i][j]=='1')
             {
               x[cnt1++]=j;
               y[cnt2++]=i;                
             }
           }    
                 
       }        
     }             
     if(y[0]==y[1]&&y[2]==y[3]&&x[1]==x[0]+1&&x[3]==x[2]+1) cout<<"A"<<endl;
     else if(x[0]==x[1]&&x[1]==x[2]&&x[2]==x[3]) cout<<"B"<<endl;
     else if(y[0]==y[1]&&y[1]==y[2]&&y[2]==y[3]) cout<<"C"<<endl;
     else if(y[1]==y[2]&&x[0]==x[3]+1) cout<<"D"<<endl;
     else if(x[1]==x[2]&&(x[3]==x[0]+2)) cout<<"E"<<endl;
     else if(y[1]==y[2]&&y[3]==y[0]+1) cout<<"F"<<endl;
     else cout<<"G"<<endl;        
   }
   //while(1);
   return 0;
 }

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

using namespace std;

char mp[8][9];

int a[7][4][2] = {
	{{0, 0}, {0, 1}, {1, 0}, {1, 1}},
	{{0, 0}, {1, 0}, {2, 0}, {3, 0}},
	{{0, 0}, {0, 1}, {0, 2}, {0, 3}},
	{{0, 1}, {1, 0}, {1, 1}, {2, 0}},
	{{0, 0}, {0, 1}, {1, 1}, {1, 2}},
	{{0, 0}, {1, 0}, {1, 1}, {2, 1}},
	{{1, 0}, {1, 1}, {0, 1}, {0, 2}}
};

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

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

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

				if (cnt == 4) {
					printf("%c\n", 'A' + k);
					goto nxt;
				}
			}
		}
		
nxt:;
	}
}

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

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

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

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(fgets(b, 64, stdin) == NULL){ break; }
		if(fgets(b, 64, stdin) == NULL){ break; }
	}
	return 0;
}

C++: import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main_format();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNext() == true) {
			int[][] map = new int[8][8];

			for (int i = 0; i < 8; i++) {
				String line = sc.nextLine();
				
				for (int j = 0; j < 8; j++) {
					map[i][j] = line.charAt(j) - '0';
				}
			}
			
			int state = 0;
			int max = 8;
			int k = 0;
			
			boolean end = false;
			for (int i = 0; i < max; i++) {
				for (int j = k; j < 8; j++) {
					if (map[i][j] == 1) {
						switch (state) {
						case 0:
							state = 1;
							max = i + 4;
							k = j - 1;
							break;
							
						case 1:
							state = 2;
							break;

						case 2:
							state = 3;
							break;

						case 3:
							System.out.println("C");
							end = true;
							break;
						
						case 4:
							if (j == k) {
								System.out.println("D");
								end = true;
							} else {
								state = 6;
							}
							break;
							
						case 5:
							if (j == k) {
								System.out.println("G");
								end = true;
							} else if (j == (k + 1)) {
								System.out.println("A");
								end = true;
							} else {
								System.out.println("E");
								end = true;
							}
								
						case 6:
							System.out.println("F");
							end = true;
							break;
						}
						
					}
					if (end == true) break;
				}
				
				if ((state == 1) || (state == 2)) {
					state = state + 3;
				} if (state == 6) {
					System.out.println("B");
					end = true;
				}
				if (end == true) break;
 			}
		}
	}
}