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

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

int main() {
	char in[8][8];
	int i, j, ans = 0, lop = 0;
	while (cin >> in[lop]) {
		if (++lop < 8)
			continue;
		lop = 0;
		ans = 0;
		for (i = 0; i < 8; i++) {
			for (j = 0; j < 8; j++) {
				if (in[i][j] == '1')
					goto end;
			}
		}
	end:
		if (in[i + 3][j] == '1') {
			ans = 1;
			goto out;
		}
		if (in[i][j+3] == '1') {
			ans = 2;
			goto out;
		}
		if (in[i + 2][j - 1] == '1') {
			ans = 3;
			goto out;
		}
		if (in[i + 1][j + 2] == '1') {
			ans = 4;
			goto out;
		}
		if (in[i + 2][j + 1] == '1') {
			ans = 5;
			goto out;
		}
		if (in[i + 1][j - 1] == '1') {
			ans = 6;
			goto out;
		}
	out:
		cout << (char)('A' + ans) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>

using namespace std;

int main()
{
	char MAP[8][8];
	int cont = 0;
	int air_cont = 0;
	bool canCont = false;
	
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 8; j++){
			cin >> MAP[i][j];
		}
	}
	//ツ債カツ端ツづーツ個ゥツづつつッツづつゥツづァツ催古」ツづ個ブツδ債ッツクツつェツ個ゥツづつつゥツづゥツづ慊づづ個凝ウツ板陳青板づーツ記ツ録
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 8; j++){
			if(MAP[i][j] == '1'){
				cont++;
				if(cont == 1){
					canCont = true;
				}
				if(cont == 4){
					//ツδ仰ーツプツ仰ュツ青ァツ終ツ猟ケ
					goto FIN;
				}
			}
			else if(canCont == true && MAP[i][j] == '0'){
				air_cont++;
			}
		}
	}
	
	FIN:;
	
	switch(air_cont){
		case 0:
			cout << "C" << endl;
			break;
		case 5:
			cout << "G" << endl;
			break;
		case 6:
			cout << "A" << endl;
			break;
		case 7:
			cout << "E" << endl;
			break;
		case 12:
			cout << "D" << endl;
			break;
		case 14:
			cout << "F" << endl;
			break;
		case 21:
			cout << "B" << endl;
			break;
		default:
			cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>

using namespace std;
typedef pair<double,double> P;




int main(){
	int field[8][8];
	string field1[9];
	int count = 0;
	while(getline(cin, field1[0])){
		if(count == 0){
			for(int i = 1;i < 8;i++){
				getline(cin, field1[i]);
			}
		}
		if(count != 0){
			for(int i = 1;i < 9;i++){
				getline(cin, field1[i]);
			}
		}

		for(int i = 0;i < 8;i++){
			for(int j = 0;j < 8;j++){
				if(field1[i][j] == '1') field[i][j] = 1;
				else field[i][j] = 0;
			}
		}
		/*for(int i = 0;i < 8;i++){
			for(int j = 0;j < 8;j++){
				cout << field[i][j];
			}
			cout << endl;
		}
		cout << endl;*/
		for(int i = 0;i < 8;i++){
			int flag = 0;
			for(int j = 0;j < 8;j++){
				if(field[i][j] == 1){
					//cout << i << j <<endl;
					if(field[i][j] == field[i][j+1]){
						if(field[i][j] == field[i+1][j]){
							if(field[i][j] == field[i+1][j+1]){
								cout << "A" << endl;
								flag = 1;break;
							}
							else if(field[i][j] == field[i+1][j-1]){
								cout << "G" << endl;
								flag = 1;break;
							}
						}
						else if(field[i][j] == field[i][j+2] && field[i][j] == field[i][j+3]){
							cout << "C" << endl;
							flag = 1;break;
						}
						else if(field[i][j] == field[i+1][j+1] && field[i][j] == field[i+1][j+2]){
							cout << "E" << endl;
							flag = 1;break;
						}
					}
					else if(field[i][j] == field[i+1][j]){
						if(field[i][j] == field[i+1][j-1] && field[i][j] == field[i+2][j-1]){
							cout << "D" << endl;
							flag = 1;break;
						}
						else if(field[i][j] == field[i+1][j+1] && field[i][j] == field[i+2][j+1]){
							cout << "F" << endl;
							flag = 1;break;
						}
					}
					else if(field[i][j] == field[i+1][j] && field[i][j] == field[i+2][j] && field[i][j] == field[i+3][j]){
						cout << "B" << endl;
						flag = 1;break;
					}
				}
			}
			if(flag == 1) break;
		}
		count++;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>


using namespace std;

char judge(vector<string> a){
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      if(a.at(i)[j] == '1'){
	// not succession
	if(a[i].at(j+1) != '1'){
	  if(a[i+1].at(j-1) == '1'){
	    return 'D';
	  }else if(a[i+1].at(j+1) == '1'){
	    return 'F';
	  }else{
	    return 'B';
	  }
	}else{
	  // in succession
	  if(a[i].at(j+2) == '1'){
	    return 'C';
	  }else if(a[i+1].at(j+2) == '1'){
	    return 'E';
	  }else if(a[i+1].at(j-1) == '1'){
	    return 'G';
	  }else{
	    return 'A';
	  }
	}
      }
    }
  }
  return 'N';
}

int main(){

  while(true){
    vector<string> a;
    for(int j=0;j<8;j++){
      string s;
      cin >> s;
      a.push_back(s);
    }
    cout << judge(a) << endl;
  }
  

}

C++: #include <iostream>

#define limit(A,X,C) ((X<A)?A:(C<X)?C:X)

char map[8+1][8]={0};

int pget(int x,int y)
{
	if(limit(0,x,7)==x && limit(0,y,7)==y)
		return map[y][x]-'0';
	return 0;
}

char check(int x, int y)
{
	if(pget(x+1,y))
	{
		if(pget(x+2,y))
			return 'C';
		if(!pget(x,y+1))
			return 'E';
		if(pget(x+1,y+1))
			return 'A';
		return 'G';
	}
	if(pget(x,y+2))
		return 'B';
	if(pget(x+1,y+2))
		return 'F';
	return 'D';
}

int main(void)
{
	do
	{
		for(int i=0; i<8; i++)
			std::cin >> map[i];
		int x,y;
		for(int j=0; j<8; j++)
		{
			for(int i=0; i<8; i++)
				if(map[j][i] == '1')
				{
					x=i;
					y=j;
					break;
				}
			if(x && y)
				break;
		}

		std::cout << check(x,y) << std::endl;
	}while(std::cin >> map[0][0]);
	
	return 0;
}