Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	board := make([][]int, 8)
	for i := range board {
		board[i] = make([]int, 8)
			for j := range board[i] {
				board[i][j] = 0
			}
	}
	var ans string
	for scanner.Scan() {
		tmp := strings.Split(scanner.Text(), "")
		for i := 0; i < 8; i++ {
			board[0][i], _ = strconv.Atoi(tmp[i])
		}
		for i := 1; i < 8; i++ {
			scanner.Scan()
			row := strings.Split(scanner.Text(), "")
			for j := 0; j < 8; j++ {
				board[i][j], _ = strconv.Atoi(row[j])
			}
		}
		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)
	}
}

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

int main(){

	string str[8];
	int valid;

	while(cin >> str[0]){
		for(int i=1; i<8; i++){
			cin >> str[i];
		}
		
		valid = 0;
		for(int i=0; i<8 && valid == 0; i++){
			for(int j=0; j<8; j++){
				if(str[i][j] == '1'){
					if(i <= 4 && str[i+3][j] == '1'){
						cout << 'B' << endl;
						valid = 1;
						break;
					}
					if(j <= 4 && str[i][j+3] == '1'){
						cout << 'C' << endl;
						valid = 1;
						break;
					}
					if(j != 0 && i <= 5 && str[i+2][j-1] == '1'){
						cout << 'D' << endl;
						valid = 1;
						break;
					}
					if(j <= 5 && i != 7 && str[i+1][j+2] == '1'){
						cout << 'E' << endl;
						valid = 1;
						break;
					}
					if(j != 7 && i <= 5 && str[i+2][j+1] == '1'){
						cout << 'F' << endl;
						valid = 1;
						break;
					}
					if(j != 0 && i != 7 && str[i+1][j-1] == '1'){
						cout << 'G' << endl;
						valid = 1;
						break;
					}
					cout << 'A' << endl;
					valid = 1;
					break;
				}
			}
		}
	}

	return 0;

}

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

int main(){
	int mass[8][8];
	
	BEGIN:
	while(scanf("%d%d%d%d%d%d%d%d",mass[0],mass[0]+1,mass[0]+2,mass[0]+3,mass[0]+4
	mass[0]+5,mass[0]+6,mass[0]+7)!=EOF)
	{
		for(int i=1;i<8;i++){
			scanf("%d%d%d%d%d%d%d%d",mass[i],mass[i]+1,mass[i]+2,mass[i]+3,mass[i]+4
				mass[i]+5,mass[i]+6,mass[i]+7);
		}
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(mass[i][j]){
					if(j==7){
						if(mass[i+1][j]){
							cout<<(mass[i+1][j-1]?"D\n":"B\n");
						}
					}else if(j==0){
						if(mass[i][j+1]){
							if(mass[i+1][j]) cout<<"A\n";
							else if(mass[i][j+2]) cout<<"C\n";
							else cout<<"E\n";
						}
						else cout<<(mass[i+1][j+1]?"F\n":"B\n");
					}else{
						if(mass[i][j+2]) cout<<"C\n";
						else if(mass[i][j+1]){
							if(mass[i+1][j]){
								cout<<(mass[i+1][j+1]?"A\n":"G\n");
							}
							else cout<<"E\n";
						}
						else if(mass[i+2][j]) cout<<"B\n";
						else cout<<(mass[i+1][j+1]?"F\n":"D\n");
					}
					goto BEGIN;
				}
			}
		}
	}
}

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
  bool field[12][12] = {};
  string s;
  while(cin >> s) {
    rep(i, 8) {
      field[0][i] = s[i] == '1';
    }
    loop(i, 1, 8) {
      cin >> s;
      loop(j, 0, 8) {
        field[i][j] = s[j] == '1';
      }
    }
   
    char ans = '.';
    rep(i, 8) {
      rep(j, 8) {
        if(field[i][j]) {
          if(field[i][j+1] && field[i+1][j] && field[i+1][j+1]) ans = 'A';
          else if(field[i+1][j] && field[i+2][j] && field[i+3][j]) ans = 'B';
          else if(field[i][j+1] && field[i][j+2] && field[i][j+3]) ans = 'C';
          else if(field[i][j+1] && field[i+1][j+1] && field[i+1][j+2]) ans = 'E';
          else if(field[i+1][j] && field[i+1][j+1] && field[i+2][j+1]) ans = 'F';
          else if(field[i+1][j] && field[i+1][j-1] && field[i+2][j-1]) ans = 'D';
          else ans = 'G';
          break;
        }
      }
      if(ans != '.') break;
    }
    cout << ans << endl;
    getline(cin, s);
  }
}