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>
#include <string>
using namespace std;

const double EPS = 1.0e-6;

int main()
{
	while(1){
		string all[8];
		bool endflg = false;
		for(int i=0; i<8; i++){
			if(!(cin>>all[i])) endflg = true;
			if(endflg) break;
		}
		if(endflg) break;

		string ans = "NG";
		for(int i=0; i<7; i++){
			bool breakflg = false;
			for(int j=0; j<7; j++){
				// ¡É©é
				if(all[i][j]-'0'==1&&all[i][j+1]-'0'==1){
					if(all[i+1][j]-'0'==1&&all[i+1][j+1]-'0'==1){
						ans = "A";
					} else if(all[i+1][j]-'0'==0&&all[i+1][j+1]-'0'==0){
						ans = "C";
					} else if(all[i+1][j]-'0'==1&&all[i+1][j+1]-'0'==0){
						ans = "G";
					} else if(all[i+1][j]-'0'==0&&all[i+1][j+1]-'0'==1){
						ans = "E";
					}
					breakflg = true;
					break;
				}
				// cÉ©é
				if(all[i][j]-'0'==1&&all[i+1][j]-'0'==1){
					if(all[i][j+1]-'0'==1&&all[i+1][j+1]-'0'==1){
						ans = "A";
					} else if(all[i][j+1]-'0'==0&&all[i+1][j+1]-'0'==0){
						ans = "B";
					} else if(all[i][j+1]-'0'==1&&all[i+1][j+1]-'0'==0){
						ans = "D";
					} else if(all[i][j+1]-'0'==0&&all[i+1][j+1]-'0'==1){
						ans = "F";
					}
					breakflg = true;
					break;
				}
			}
			if(breakflg) break;
		}
		if(ans == "NG"){
			// ·û`
			for(int i=0; i<7; i++){
				if(all[7][i]-'0'==1){
					ans = "C";
					break;
				}
			}
			for(int i=0; i<7; i++){
				if(all[i][7]-'0'==1){
					ans = "B";
					break;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;

int main(){
    char boa[8][8];
    while(1){
        
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(!(cin>>boa[i][j]))
                    return 0;
            }
        }
        int bo[8][8];
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                bo[i][j]=boa[i][j]-'0';
            }
        }
        
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(bo[i][j]==1){
                    if(i<8&&j<8){
                        if(bo[i+1][j]==1&&bo[i][j+1]==1&&bo[i+1][j+1]){
                            cout<<"A"<<endl;
                            goto next;
                        }
                    }
                    if(j<4){
                        if(bo[i][j+1]&&bo[i][j+2]&&bo[j+3]){
                            cout<<"C"<<endl;goto next;
                        }
                            
                    }
                    if(i<4){
                        if(bo[i+1][j]&&bo[i+2][j]&&bo[i+3][j]){
                            cout<<"B"<<endl;goto next;
                        }
                        
                    }
                    if(i<7&&i>0&&j<7){
                        if(bo[i+1][j]&&bo[i][j+1]&&bo[i-1][j+1]){
                            cout<<"D"<<endl;goto next;
                        }
                    }
                    if(i<7&&j<6){
                        if(bo[i][j+1]&&bo[i+1][j+1]&&bo[i+1][j+2]){
                            cout<<"E"<<endl;goto next;
                        }
                    }
                    if(i<6&&j<7){
                        if(bo[i+1][j]&&bo[i+1][j+1]&&bo[i+2][j+1]){
                            cout<<"F"<<endl;goto next;
                        }
                    }
                    if(i<6&&j>0){
                        if(bo[i+1][j]&&bo[i+1][j-1]&&bo[i+2][j-1]){
                            cout<<"G"<<endl;goto next;
                        }
                    }
                    
                }
            }
        }
        
    next:;
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  vector<string> S(8);

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

    vector<string> shape = {"B", "C", "D", "E", "F", "G", "A"};
    vector<int> dx = {0, 3, 1, 2, 1, 2, 1};
    vector<int> dy = {3, 0, -2, 1, 2, -1, 1};

    bool flag = false;
    for(int x=0; x<8; x++){
      for(int y=0; y<8; y++){
        for(int i=0; i<7; i++){
          int cx = x + dx[i], cy = y + dy[i];
          if(0 <= cx && cx < 8 && 0 <= cy && cy < 8){
            if(S[y][x] == '1' && S[cy][cx] == '1'){
              cout << shape[i] << endl;
              flag = true;
            }
          }
          if(flag) break;
        }
        if(flag) break;
      }
      if(flag) break;
    }
  }
}

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

bool vd(int x, int y){
	return x>=0 && y>=0 && y<8 && x<8;
}

char solve(char sol[6]){
//	for(int x=0;x<6;++x)cout<<sol[x]<<" ";
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='0' && sol[3]=='0' && sol[4]=='1' && sol[5]=='1')return 'F';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='1' && sol[3]=='1' && sol[4]=='1' && sol[5]=='0')return 'G';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='1' && sol[3]=='0' && sol[4]=='0' && sol[5]=='1')return 'E';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='0' && sol[3]=='1' && sol[4]=='1' && sol[5]=='0')return 'D';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='1' && sol[3]=='0' && sol[4]=='0' && sol[5]=='0')return 'C';
	if(sol[0]=='0' && sol[1]=='1' && sol[2]=='0' && sol[3]=='0' && sol[4]=='1' && sol[5]=='0')return 'B';
	return 'A';
}

int main(){
	char j;
	char mat[8][8];
	while(cin>>j){
		pair<int,int> init = make_pair(-1,-1);
		mat[0][0] = j;
		if(j=='1'){
			init.first = 0;init.second = 0;
		}
		for(int x=1;x<64;++x){
			cin>>j;mat[x/8][x%8] = j;
			if(j=='1' && init.first == -1){
				init.first = x/8;
				init.second = x%8;

			}
		}
		//cout<<init.first<<":"<<init.second<<endl;
		char sol[6];
		int cnt = 0;
		for(int x=0;x<2;++x){
			for(int y=-1;y<2;++y){
				if(vd(init.first + x , init.second + y)){
					sol[cnt++] = mat[init.first + x][init.second + y];
				}else{
					sol[cnt++] = '0';
				}
			}
		}
		cout<<solve(sol)<<endl;
	}		
	return 0;
}