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 < 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<stdio.h>

int main(){
	char masu[15][15];
	int i,j;
	
	while(scanf("%c", &masu[0][0]) != EOF){
		for(i=1;i<9;i++)scanf("%c", &masu[0][i]);
		
		for(i=1;i<8;i++){
			for(j=0;j<9;j++){
				scanf("%c", &masu[i][j]);
			}
		}
		scanf("%c", &masu[15][15]);
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				if(masu[i][j]=='1'   && masu[i+1][j]=='1' && masu[i][j+1]=='1'   && masu[i+1][j+1]=='1')puts("A");
				if(masu[i][j]=='1'   && masu[i+1][j]=='1' && masu[i+2][j]=='1'   && masu[i+3][j]=='1')  puts("B");
				if(masu[i][j]=='1'   && masu[i][j+1]=='1' && masu[i][j+2]=='1'   && masu[i][j+3]=='1')  puts("C");
				if(masu[i][j+1]=='1' && masu[i+1][j]=='1' && masu[i+2][j]=='1'   && masu[i+1][j+1]=='1')puts("D");
				if(masu[i][j]=='1'   && masu[i][j+1]=='1' && masu[i+1][j+1]=='1' && masu[i+1][j+2]=='1')puts("E");
				if(masu[i][j]=='1'   && masu[i+1][j]=='1' && masu[i+1][j+1]=='1' && masu[i+2][j+1]=='1')puts("F");
				if(masu[i][j+1]=='1' && masu[i+1][j]=='1' && masu[i][j+2]=='1'   && masu[i+1][j+1]=='1')puts("G");
			}
		}
	}
	return 0;
}

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

#define SIZE 8

int main() {
	string source[SIZE];
	while (!cin.eof()) {
		for (int i = 0; i < SIZE; i++) {
			cin >> source[i];
		}

		int map[16][16], x = SIZE, y = SIZE;
		for (int i = 0; i < SIZE; i++) {
			for (int j = 0; j < SIZE; j++) {
				map[i + 4][j + 4] = source[i][j] == '1' ? 1 : 0;
				if (source[i][j] == '1' && j < x && i < y) {
					x = j;
					y = i;
				}
			}
		}
		x += 4;
		y += 4;

		if (map[y + 1][x + 1] == 1) {
			if (map[y][x + 1] == 1 && map[y + 1][x] == 1) {
				cout << "A";
			} else if (map[y + 2][x + 1] == 1) {
				cout << "F";
			} else if (map[y + 1][x + 2] == 1) {
				cout << "E";
			}
		} else if (map[y - 1][x - 1] == 1) {
			if (map[y][x + 1] == 1) {
				cout << "G";
			} else if (map[y + 2][x - 1] == 1) {
				cout << "D";
			}
		} else if (map[y + 3][x]) {
			cout << "B";
		} else {
			cout << "C";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to) 

int main() {
	int t[7][4][4] = {{{1, 1, 0, 0},
					   {1, 1, 0, 0},
					   {0, 0, 0, 0},
					   {0, 0, 0, 0}},

					  {{1, 0, 0, 0},
					   {1, 0, 0, 0},
					   {1, 0, 0, 0},
					   {1, 0, 0, 0}},

					  {{1, 1, 1, 1},
					   {0, 0, 0, 0},
					   {0, 0, 0, 0},
					   {0, 0, 0, 0}},
					  
					  {{0, 1, 0, 0},
			      	   {1, 1, 0, 0},
					   {1, 0, 0, 0},
					   {0, 0, 0, 0}},
					  
					  {{1, 1, 0, 0},
					   {0, 1, 1, 0},
					   {0, 0, 0, 0},
					   {0, 0, 0, 0}},
					  
					  {{1, 0, 0, 0},
					   {1, 1, 0, 0},
					   {0, 1, 0, 0},
					   {0, 0, 0, 0}},
					
				   	  {{0, 1, 1, 0},
				   	   {1, 1, 0, 0},
					   {0, 0, 0, 0},
					   {0, 0, 0, 0}}};
	string str;
	while(cin >> str) {
		vector<string> s(8);
		s[0] = str;
		int board[11][11];
		rep2(i,1,8) {
			cin >> s[i];
		}
		
		rep(i,8) {
			rep(j,8) {
				board[i][j] = s[i][j] - '0';
			}
		}
		rep2(i,8,11) {
			rep2(j,8,11) {
				board[i][j] = 0;
			}
		}
		rep(i,64) {
			bool f = 1;
			rep(k,7) {
				f = 1;
				rep(l,16) {
					if(board[i / 8 + l / 4][i % 8 + l % 4] != t[k][l / 4][l % 4]) {
						f = 0;
						break;
					}
				}
				if(f) {
					cout << (char) (k + 'A') << endl;
					break;
				}
			}
			if(f) break;
		}
	}
	return 0;
}

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

int main() {
  char x;
  int k=0;
  while(cin.get(x)) {
    if(x == 1) {
      k = k % 7;
      break;
    }
    k++;
  }
  cin.get(x);
  if(x == 1) {// A,C,E,G
    cin.get(x);
    if(x == 1) // C
      cout << "C" << endl;
    else if(x == 0) {//A,E,G
      for(int i=0;i<6;i++){
        cin.get(x);
      }
      if(x == 1)
        cout << "G" << endl; // G
      else if(x == 0) {
        cin.get(x);
        if(x == 1)
          cout << "A" << endl; // A
        else
          cout << "E" << endl; // E
      }
    }
  }
  else if(x == 0) {//B,D,F
    for(int i=0;i<6;i++) {
      cin.get(x);
    }
    if(x == 1)
      cout << "D" << endl;
    else if(x == 0) {
      cin.get(x);
      cin.get(x);
      if(x == 1)
        cout << "F" << endl;
      else
        cout << "B" << endl;
    }
  }
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	char ans = '0', wk;
	int F[16][16];
	while(cin >> wk)
	{
		memset(F, 0, sizeof(F));
		if(wk == '\n')
		{
			continue;
		}
		F[0][0] = wk - '0';
		ans = '0';


		for(int i = 0; i < 8; i++)
		{
			for(int j = 0; j < 8; j++)
			{
				if(i == 0 && j == 0)
					continue;
				cin >> wk;
				F[i][j] = wk - '0';
			}
		}

		for(int i = 0; i < 8; i++)
		{
			for(int j = 0; j < 8; j++)
			{
				if(F[i][j] && F[i][j+1] && F[i+1][j] && F[i+1][j+1])
				{
					ans = 'A';
					break;
				}
				if(F[i][j] && F[i+1][j] && F[i+2][j] && F[i+3][j])
				{
					ans = 'B';
					break;
				}
				if(F[i][j] && F[i][j+1] && F[i][j+2] && F[i][j+3])
				{
					ans = 'C';
					break;
				}
				if(F[i][j] && F[i+1][j] && F[i+1][j-1] && F[i+2][j-1])
				{
					ans = 'D';
					break;
				}
				if(F[i][j] && F[i][j+1] && F[i+1][j+1] && F[i+1][j+2])
				{
					ans = 'E';
					break;
				}
				if(F[i][j] && F[i+1][j] && F[i+1][j+1] && F[i+2][j+1])
				{
					ans = 'F';
					break;
				}
				if(F[i][j] && F[i][j+1] && F[i-1][j+1] && F[i-1][j+2])
				{
					ans = 'G';
					break;
				}
			}
			if(ans != '0')
			{
				break;
			}
		}

		cout << ans << endl;
	}
}