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

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
is(string &s){int c; s = "";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

typedef vector<string> v;

char pat_search(v &a) {
	static auto p = [&a](int i, int j) {
		return i < 8 && j < 8 && a[i][j] == '1';};
	for (int i = 0; i < 8; i++)
		for (int j = 0; j < 8; j++)
			if (a[i][j] == '1') {
				return p(i + 1, j + 1)? p(i, j + 1)? p(i + 1, j + 2)? 'E' : 'A' : 'F' :
					p(i, j + 1)? p(i, j + 2)? 'C' : 'G' : p(i + 2, j)? 'B' : 'D';
			}
	return 'X';
}

int main() {
	v a(8);
	do {
		for (auto &s: a)
			scan(s);
		out(pat_search(a), '\n');
	} while (gcu() == '\n');
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define X first
#define Y second
#define WIDTH 8
#define HEIGHT 8

using namespace std;

vector<string> init(){
	vector<string> map;
	for(int i = 0; i < HEIGHT; i++){
		string tmp;
		getline(cin,tmp);
		map.push_back(tmp);
	}
	return map;
}

void countNum(vector<string> map, int *count){
	int counter = -1;
	
	for(int i = 0; i < HEIGHT; i++){
		for(int j = 0; j < WIDTH ; j++){
			if(map[i][j] == '1'){
				counter++;
				if(counter == 3) return;
			}
			else{
				if(counter >= 0) count[counter]++;
			}
		}
	}

	return;
}


char checkChar(int *count){
	if(count[0] == 0 && count[1] == 6 && count[2] == 0){
		return 'A';
	}
	else if(count[0] == 7 && count[1] == 7 && count[2] == 7){
		return 'B';
	}
	else if(count[0] == 0 && count[1] == 0 && count[2] == 0){
		return 'C';
	}
	else if(count[0] == 6 && count[1] == 0 && count[2] == 6){
		return 'D';
	}
	else if(count[0] == 0 && count[1] == 7 && count[2] == 0){
		return 'E';
	}
	else if(count[0] == 7 && count[1] == 0 && count[2] == 7){
		return 'F';
	}
	else if(count[0] == 0 && count[1] == 5 && count[2] == 0){
		return 'G';
	}
}



int main(){
	
	while(1){
		vector<string> map = init();
		int count[] = {0, 0, 0};
		countNum(map, count);
		cout << checkChar(count) << endl;
		//入力で一行改行が入ってしまうのでそれ対策
		string tmp;
		getline(cin, tmp);
	}
	return 0;
}

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

int main()
{
	while(!cin.eof())
	{
		long a[8] = {0};
		for(int i = 0; i < 8; i++)
		{
			long x;
			cin >> x;
			for(int j = 0; j < 8; j++)
			{
				a[i] += (x % 10) << j;
				x /= 10;
			}
		}
		if(cin.eof())
			break;

		char c = 'A';
		for(int i = 0; i < 7; i++)
			for(int j = 0; j < 7; j++)
				if(a[i] == 3 << j)
					if(a[i + 1] == 3 << j)
						goto END;

		c = 'B';
		for(int i = 0; i < 5; i++)
			for(int j = 0; j < 8; j++)
				if(a[i] == (1 << j))
					if(a[i + 1] == (1 << j))
					{
						//cout << "B " << (1 << j) << endl;
						goto END;
					}

		c = 'C';
		for(int i = 0; i < 8; i++)
			for(int j = 0; j < 5; j++)
			{
				//cout << 'C' << ' ' << (15 << j) << endl;
				if(a[i] == 15 << j)
					goto END;

			}
		c = 'D';
		for(int i = 0; i < 6; i++)
			for(int j = 0; j < 7; j++)
				if(a[i] == 1 << j)
					if(a[i + 1] == 3 << j)
						goto END;

		c = 'E';
		for(int i = 0; i < 7; i++)
			for(int j = 0; j < 7; j++)
				if(a[i] == 3 << j)
					if(a[i + 1] == 3 << (j-1))
						goto END;

		c = 'F';
		for(int i = 0; i < 6; i++)
			for(int j = 0; j < 8; j++)
				if(a[i] == 1 << j)
					goto END;

		c = 'G';
		for(int i = 0; i < 7; i++)
			for(int j = 0; j < 6; j++)
				if(a[i] == 3 << j)
					if(a[i + 1] == 3 << (j + 1))
						goto END;

		cout << "error" << endl;
		break;

	END:
		cout << c << endl;
	}
	return 0;
}