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 <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	while(1){
		char field[8][9];
		int left = 8, right = 0, top = 8, bottom = 0;
		rep(y, 8){
			if(scanf("%s", field[y]) == EOF)
				return 0;
			rep(x, 8){
				if(field[y][x] == '1'){
					left = min(left, x);
					right = max(right, x);
					top = min(top, y);
					bottom = max(bottom, y);
				}
			}
		}

		int w = right - left + 1, h = bottom - top + 1;
		if(h==4)
			puts("B");
		else if(w==4)
			puts("C");
		else if(w==2 && h==2)
			puts("A");
		else if(w==2 && h==3)
			puts(field[top][left] == '1' ? "F" : "D");
		else
			puts(field[top][left] == '1' ? "E" : "G");
	}
}

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

}