Problem:


平面上の図形

縦 8、横 8 のマスからなる図 1 のような平面があります。

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

図１

この平面上に、以下の A から G の図形のどれかが一つだけ置かれています。

	

A

	

		
■■

		
■■

		

		

	

	

B

	

		
■

		
■

		
■

		
■

	

	

C

	

		
■■■■

		

		

		

	

	

D

	

		
■

		
■■

		
■

		

	

	

E

	

		
■■

		
■■

		

		

	

	

F

	

		
■

		
■■

		
■

		

	

	

G

	

		
■■

		
■■

		

		

	

		

たとえば、次の図 2 の例では E の図形が置かれています。

□□□□□□□□

□□□□□□□□

□■■□□□□□

□□■■□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

図２

平面の中で図形が占めているマスを 1、占めていないマスを 0 で表現した数字の列を読み込んで、置かれている図形の種類（A〜G）を出力するプログラムを作成してください。

ただし、ひとつの平面に置かれている図形は必ず１つで、複数の図形が置かれていることはありません。また、A〜G で表される図形以外のものが置かれていることはありません。

Input

入力は複数のデータセットからなります。

１つのデータセットとして、平面の中で図形が占めているマスを 1、占めていないマスを 0 で表現した 8 文字からなる 8 つの文字列が与えられます。例えば、図 2 に対応する文字列の並びは次のようになります。

00000000

00000000

01100000

00110000

00000000

00000000

00000000

00000000

データセットの間は１つの空行で区切られています。データセットの数は 50 を超えません。

Output

各データセットごとに、平面に与えられた図形の種類（A〜G のいずれか）を１行に出力してください。

Sample Input

00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000

00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000

00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000

Output for the Sample Input

E
C
A



Sample input:
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000

00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000

00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000


Sample output:
E
C
A

Submission status: Wrong Answer

Solution code:
while True:
    try:
        n = 0
        s = ["","","","",""]
        for i in range(8):
            tmp = raw_input()
            if int(tmp) != 0:
                s[n] = tmp
                n+=1
        if s[0].count("1") == 4:
            print "C"
        elif s[0].count("1") == 1:
            if n == 4:
                print "B"
            if s[0].index("1") == s[1].index("1"):
                print "F"
            elif s[0].index("1") < s[1].index("1"):
                print "D"
        elif s[0].count("1") == 2:
            if s[0].index("1") == s[1].index("1"):
                print "A"
            elif s[0].index("1") < s[1].index("1"):
                print "E"
            else:
                print "G"
        raw_input()
    except:
        break

Submission status: Wrong Answer

Solution code:
def trim():
    num=[]
    N=[input() for _ in range(8)]
    for x in range(8):
        for y in range(8):
            if N[y][x]=="1":
                if not num:
                    refer=(x,y)
                num.append((x,y))
    num=[(x-refer[0],y-refer[1]) for x,y in num]
    return num
def point(point):
    if point==[(0,0),(0,1),(1,0),(1,1)]:print("A")
    if point==[(0,0),(0,1),(0,2),(0,3)]:print("B")
    if point==[(0,0),(1,0),(2,0),(3,0)]:print("C")
    if point==[(0,0),(0,1),(1,-1),(1,0)]:print("D")
    if point==[(0,0),(1,0),(1,1),(2,1)]:print("E")
    if point==[(0,0),(0,1),(1,1),(1,2)]:print("F")
    if point==[(0,0),(1,-1),(1,0),(2,-1)]:print("G")
while True:
    try:
        point(trim())
    except:break

Submission status: Wrong Answer

Solution code:
def trim(N):
    num=[]
    for x in range(8):
        for y in range(8):
            if N[y][x]=="1":
                if not num:
                    refer=(x,y)
                num.append((x,y))
    num=[(x-refer[0],y-refer[1]) for x,y in num]
    return num
def point(point):
    if point==[(0,0),(0,1),(1,0),(1,1)]:print("A")
    if point==[(0,0),(0,1),(0,2),(0,3)]:print("B")
    if point==[(0,0),(1,0),(2,0),(3,0)]:print("C")
    if point==[(0,0),(0,1),(1,-1),(1,0)]:print("D")
    if point==[(0,0),(1,0),(1,1),(2,1)]:print("E")
    if point==[(0,0),(0,1),(1,1),(1,2)]:print("F")
    if point==[(0,0),(1,-1),(1,0),(2,-1)]:print("G")
while True:
    try:
        point(trim(N=[input() for _ in range(8)]))
    except:break

Submission status: Wrong Answer

Solution code:
def trim(N):
    num=[]
    for x in range(8):
        for y in range(8):
            if N[y][x]=="1":
                if not num:
                    refer=(x,y)
                num.append((x,y))
    num=[(x-refer[0],y-refer[1]) for x,y in num]
    return num
def points(point):
    if point==[(0,0),(0,1),(1,0),(1,1)]:print("A")
    if point==[(0,0),(0,1),(0,2),(0,3)]:print("B")
    if point==[(0,0),(1,0),(2,0),(3,0)]:print("C")
    if point==[(0,0),(0,1),(1,-1),(1,0)]:print("D")
    if point==[(0,0),(1,0),(1,1),(2,1)]:print("E")
    if point==[(0,0),(0,1),(1,1),(1,2)]:print("F")
    if point==[(0,0),(1,-1),(1,0),(2,-1)]:print("G")
while True:
    try:
        N=[input() for _ in range(8)]
        points(trim(N))
    except:break

Submission status: Wrong Answer

Solution code:
import sys
s=p=0
for l in sys.stdin:
	if l.strip()=="":
		s=p=0
		continue
	if s==5:continue
	t=int(l)
	c=l.count("1")
	if c==4:
		s=5
		print"C"
	if s==1:
		if c==1:print"B"
		elif p>t:print"D"
		else: print"F"
		s=5
	if s==2:
		if p>t:print"E"
		elif p==t:print"A"
		else: print"G"
		s=5
	else:
		p=t
		s=c

Submission status: Wrong Answer

Solution code:
import sys
s=p=0
for l in sys.stdin:
	if l.strip()=="":
		s=p=0
		continue
	if s==5:continue
	t=int(l)
	c=l.count("1")
	if c==4:
		s=5
		print"C"
	if s==1:
		if c==1:print"B"
		elif p>t:print"D"
		else: print"F"
		s=5
	elif s==2:
		if p>t:print"E"
		elif p==t:print"A"
		else: print"G"
		s=5
	else:
		p=t
		s=c

Submission status: Wrong Answer

Solution code:
def university(xxx, pattern):
    tate = 0
    yoko = 1
    for current_tate in range(8-xxx[tate]+1):
        for current_yoko in range(8-xxx[yoko]+1):
            if absolutely_fantastic(current_tate, current_yoko):
                return True

def absolutely_fantastic(current_tate, current_yoko):
    tate = 0
    yoko = 1
    run = []
    for add_tate in range(xxx[tate]):
        for add_yoko in range(xxx[yoko]):
            run.append(mapppp[current_tate+add_tate][current_yoko+add_yoko])
    if run == pattern:
        print xxx[2]
        return True

A = {(2,2,'A'):[1,1,1,1]}
B = {(4,1,'B'):[1,1,1,1]}
C = {(1,4,'C'):[1,1,1,1]}
D = {(3,2,'D'):[0,1,1,1,1,0]}
E = {(2,3,'E'):[1,1,0,0,1,1]}
F = {(3,2,'F'):[1,0,1,1,0,1]}
G = {(2,3,'G'):[0,1,1,1,1,0]}
lis = [A,B,C,D,E,F,G]
mapppp = []
for i in range(8):
    input_line = raw_input()
    yoko = [int(char) for char in input_line]
    mapppp.append(yoko)
for XXX in lis:
    flag = False
    for xxx, pattern in XXX.items():
        if university(xxx, pattern):
            flag = True
            break
    if flag == True:
        break
raw_input()

Submission status: Wrong Answer

Solution code:
def university(xxx, pattern):
    tate = 0
    yoko = 1
    for current_tate in range(8-xxx[tate]+1):
        for current_yoko in range(8-xxx[yoko]+1):
            if absolutely_fantastic(current_tate, current_yoko):
                return True

def absolutely_fantastic(current_tate, current_yoko):
    tate = 0
    yoko = 1
    run = []
    for add_tate in range(xxx[tate]):
        for add_yoko in range(xxx[yoko]):
            run.append(mapppp[current_tate+add_tate][current_yoko+add_yoko])
    if run == pattern:
        print xxx[2]
        return True

A = {(2,2,'A'):[1,1,1,1]}
B = {(4,1,'B'):[1,1,1,1]}
C = {(1,4,'C'):[1,1,1,1]}
D = {(3,2,'D'):[0,1,1,1,1,0]}
E = {(2,3,'E'):[1,1,0,0,1,1]}
F = {(3,2,'F'):[1,0,1,1,0,1]}
G = {(2,3,'G'):[0,1,1,1,1,0]}
lis = [A,B,C,D,E,F,G]
mapppp = []
for i in range(8):
    input_line = raw_input()
    yoko = [int(char) for char in input_line]
    mapppp.append(yoko)
for XXX in lis:
    flag = False
    for xxx, pattern in XXX.items():
        if university(xxx, pattern):
            flag = True
            break
    if flag == True:
        break

Submission status: Wrong Answer

Solution code:
def university(xxx, pattern):
    tate = 0
    yoko = 1
    for current_tate in range(8-xxx[tate]+1):
        for current_yoko in range(8-xxx[yoko]+1):
            if absolutely_fantastic(current_tate, current_yoko):
                return True

def absolutely_fantastic(current_tate, current_yoko):
    tate = 0
    yoko = 1
    run = []
    for add_tate in range(xxx[tate]):
        for add_yoko in range(xxx[yoko]):
            run.append(mapppp[current_tate+add_tate][current_yoko+add_yoko])
    if run == pattern:
        print xxx[2]
        return True

A = {(2,2,'A'):[1,1,1,1]}
B = {(4,1,'B'):[1,1,1,1]}
C = {(1,4,'C'):[1,1,1,1]}
D = {(3,2,'D'):[0,1,1,1,1,0]}
E = {(2,3,'E'):[1,1,0,0,1,1]}
F = {(3,2,'F'):[1,0,1,1,0,1]}
G = {(2,3,'G'):[0,1,1,1,1,0]}
lis = [A,B,C,D,E,F,G]
mapppp = []
while True:
    try:
        for i in range(8):
            input_line = raw_input()
            yoko = [int(char) for char in input_line]
            mapppp.append(yoko)
        for XXX in lis:
            flag = False
            for xxx, pattern in XXX.items():
                if university(xxx, pattern):
                    flag = True
                    break
            if flag == True:
                break
        raw_input()
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
def university(xxx, pattern):
    tate = 0
    yoko = 1
    for current_tate in range(8-xxx[tate]+1):
        for current_yoko in range(8-xxx[yoko]+1):
            if absolutely_fantastic(current_tate, current_yoko):
                return True

def absolutely_fantastic(current_tate, current_yoko):
    tate = 0
    yoko = 1
    run = []
    for add_tate in range(xxx[tate]):
        for add_yoko in range(xxx[yoko]):
            run.append(mapppp[current_tate+add_tate][current_yoko+add_yoko])
    if run == pattern:
        print xxx[2]
        return True

A = {(2,2,'A'):[1,1,1,1]}
B = {(4,1,'B'):[1,1,1,1]}
C = {(1,4,'C'):[1,1,1,1]}
D = {(3,2,'D'):[0,1,1,1,1,0]}
E = {(2,3,'E'):[1,1,0,0,1,1]}
F = {(3,2,'F'):[1,0,1,1,0,1]}
G = {(2,3,'G'):[0,1,1,1,1,0]}
lis = [A,B,C,D,E,F,G]
mapppp = []
while True:
    try:
        input_line = raw_input()
        if input_line:
            yoko = [int(char) for char in input_line]
            mapppp.append(yoko)
        else:
            for XXX in lis:
                flag = False
                for xxx, pattern in XXX.items():
                    if university(xxx, pattern):
                        flag = True
                        break
                if flag == True:
                    break
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
while True:
	try:
		code = [raw_input() for _ in range(8)]
	except EOFError:
		break
	
	code = "".join(code)
	
	if not "1" in code:
		break
	
	str(code)
	check = 0
	for var in range(0, len(code)):
		if int(code[var:var+1]) == 1:
			check = var
			break
	
	if int(code[check+1:check+2]) == 1 and int(code[check+8:check+9]) == 1:
			if int(code[check+9:check+10]) == 1:
				print "A"
			if int(code[check+7:check+8]) == 1:
				print "G"
	elif int(code[check+1:check+2]) == 1:
		if int(code[check+2:check+3]) == 1 and int(code[check+3:check+4]) == 1:
			print "C"
		if int(code[check+9:check+10]) == 1 and int(code[check+10:check+11]) == 1:
			print "E"
	elif int(code[check+8:check+9]) == 1:
		if int(code[check+16:check+17]) == 1 and int(code[check+24:check+25]) == 1:
			print "B"
		if int(code[check+7:check+8]) == 1 and int(code[check+15:check+16]) == 1:
			print "D"
		if int(code[check+9:check+10]) == 1 and int(code[check+17:check+18]) == 1:
			print "F"

Submission status: Wrong Answer

Solution code:
while True:
	try:
		code = [raw_input() for _ in range(8)]
	except EOFError:
		break
	
	code = "".join(code)
	
	if not "1" in code:
		break
	
	str(code)
	code += "00000000"
	check = 0
	for var in range(0, len(code)):
		if int(code[var:var+1]) == 1:
			check = var
			break
	
	if int(code[check+1:check+2]) == 1 and int(code[check+8:check+9]) == 1:
			if int(code[check+9:check+10]) == 1:
				print "A"
			if int(code[check+7:check+8]) == 1:
				print "G"
	elif int(code[check+1:check+2]) == 1:
		if int(code[check+2:check+3]) == 1 and int(code[check+3:check+4]) == 1:
			print "C"
		if int(code[check+9:check+10]) == 1 and int(code[check+10:check+11]) == 1:
			print "E"
	elif int(code[check+8:check+9]) == 1:
		if int(code[check+16:check+17]) == 1 and int(code[check+24:check+25]) == 1:
			print "B"
		if int(code[check+7:check+8]) == 1 and int(code[check+15:check+16]) == 1:
			print "D"
		if int(code[check+9:check+10]) == 1 and int(code[check+17:check+18]) == 1:
			print "F"

Submission status: Wrong Answer

Solution code:
while True:
	try:
		code = [raw_input() for _ in range(8)]
	except EOFError:
		break
	
	code = "".join(code)
	
	if not "1" in code:
		break
	
	str(code)
	code += "00000000"
	check = 0
	for var in range(0, len(code)):
		if int(code[var:var+1]) == 1:
			check = var
			break
	
	if int(code[check+1:check+2]) == 1 and int(code[check+8:check+9]) == 1:
			if int(code[check+9:check+10]) == 1:
				print "A"
			elif int(code[check+7:check+8]) == 1:
				print "G"
	elif int(code[check+1:check+2]) == 1:
		if int(code[check+2:check+3]) == 1 and int(code[check+3:check+4]) == 1:
			print "C"
		elif int(code[check+9:check+10]) == 1 and int(code[check+10:check+11]) == 1:
			print "E"
	elif int(code[check+8:check+9]) == 1:
		if int(code[check+16:check+17]) == 1 and int(code[check+24:check+25]) == 1:
			print "B"
		elif int(code[check+7:check+8]) == 1 and int(code[check+15:check+16]) == 1:
			print "D"
		elif int(code[check+9:check+10]) == 1 and int(code[check+17:check+18]) == 1:
			print "F"

Submission status: Wrong Answer

Solution code:
ans=['A','B','C','D','E','F','G']
def sol(x):
    for i in range(8):
        for j in range(8):
            if i<7 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1':
                    return 0
            if j<5:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+2][j]=='1' and x[i+3][j]=='1':
                    return 1
            if i<5:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i][j+2]=='1' and x[i][j+3]=='1':
                    return 2
            if i<6 and 0<j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1' and x[i+2][j-1]=='1':
                    return 3
            if i<7 and j<6:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1' and x[i+1][j+2]=='1':
                    return 4
            if i<6 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j+1]=='1' and x[i+2][j+1]=='1':
                    return 5
            if i<5:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i][j+2]=='1' and x[i][j+3]=='1':
                    return 6


while 1:
    l=[]
    try:
        for i in range(8):
            l.append(raw_input())
        print ans[sol(l)]
        raw_input()
    except:
        break

Submission status: Wrong Answer

Solution code:
ans=['A','B','C','D','E','F','G']
def sol(x):
    for i in range(8):
        for j in range(8):
            if i<7 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1':
                    return 0
            if j<5:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+2][j]=='1' and x[i+3][j]=='1':
                    return 1
            if i<5:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i][j+2]=='1' and x[i][j+3]=='1':
                    return 2
            if i<6 and 0<j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1' and x[i+2][j-1]=='1':
                    return 3
            if i<7 and j<6:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1' and x[i+1][j+2]=='1':
                    return 4
            if i<6 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j+1]=='1' and x[i+2][j+1]=='1':
                    return 5
            if i<7 and 0<j<6:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1':
                    return 6


while 1:
    l=[]
    try:
        for i in range(8):
            l.append(raw_input())
        print ans[sol(l)]
        raw_input()
    except:
        break

Submission status: Wrong Answer

Solution code:
ans=['A','B','C','D','E','F','G']
def sol(x):
    for i in range(8):
        for j in range(8):
            if i<7 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1':
                    return 0
            if i<5:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+2][j]=='1' and x[i+3][j]=='1':
                    return 1
            if j<5:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i][j+2]=='1' and x[i][j+3]=='1':
                    return 2
            if i<6 and 0<j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1' and x[i+2][j-1]=='1':
                    return 3
            if i<7 and j<6:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1' and x[i+1][j+2]=='1':
                    return 4
            if i<6 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j+1]=='1' and x[i+2][j+1]=='1':
                    return 5
            if i<7 and 0<j<6:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1':
                    return 6


while 1:
    l=[]
    try:
        for i in range(8):
            l.append(raw_input())
        print ans[sol(l)]
        raw_input()
    except:
        break

Submission status: Wrong Answer

Solution code:
ans=['A','B','C','D','E','F','G']
def sol(x):
    for i in range(8):
        for j in range(8):
            if i<7 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1':
                    return 0
            if i<5:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+2][j]=='1' and x[i+3][j]=='1':
                    return 1
            if j<5:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i][j+2]=='1' and x[i][j+3]=='1':
                    return 2
            if i<6 and 0<j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1' and x[i+2][j-1]=='1':
                    return 3
            if i<7 and j<6:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1' and x[i+1][j+2]=='1':
                    return 4
            if i<6 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j+1]=='1' and x[i+2][j+1]=='1':
                    return 5
            if i<7 and 0<j<7:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1':
                    return 6


while 1:
    l=[]
    try:
        for i in range(8):
            l.append(raw_input())
        print ans[sol(l)]
        raw_input()
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
	surface = [list(raw_input()) for _ in range(0, 8)]

	surf = []
	for i in range(0, 8):
		if "1" in surface[i]:
			surf.append(surface[i])
	
	if len(surf) == 1 : print "C"
	else:
		if len(surf) == 2:
			x = surf[0].index("1")
			y = surf[1].index("1")
			if x - y == 0 : print "A"
			elif x - y == -1 : print "E"
			elif x - y ==  1 : print "G"
		elif len(surf) == 3:
			x = surf[0].index("1")
			y = surf[1].index("1")
			if x - y == -1 : print "D"
			elif x - y == 0 : print "F"
		elif len(surf) == 4 : print "B"
		
	try:
		raw_input()
	except EOFError:
		break

Submission status: Wrong Answer

Solution code:
#encoding=utf-8
import sys

def inp():
    fe, fe1 = [], []
    for line in sys.stdin:
        fe += line.split()
        
    i,j = 0,8
    while True:
        fe1 = fe[i:j]
        if a(fe1):
            if b(fe1):
                if c(fe1):
                    if d(fe1):
                        if e(fe1):
                            if f(fe1):
                                if g(fe1):
                                    pass

        i, j =i + 8,j + 8
        if j > len(fe): break

def a(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i+1][j]==fe1[i+1][j+1]=="1":
                        print "A"
                        return False
                except:
                    pass
    return True

def b(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i+1][j]==fe1[i+2][j]==fe1[i+3][j]=="1":
                        print "B"
                        return False
                except:
                    pass
    return True

def c(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i][j+2]==fe1[i][j+3]=="1":
                        print "C"
                        return False
                except:
                    pass
    return True

def d(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i+1][j-1]==fe1[i+1][j]==fe1[i+2][j-1]=="1":
                        print "D"
                        return False
                except:
                    pass
    return True

def e(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i+1][j+1]==fe1[i+1][j+2]=="1":
                        print "E"
                        return False
                except:
                    pass
    return True

def f(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i+1][j]==fe1[i+1][j+1]==fe1[i+2][j+1]=="1":
                        print "F"
                        return False
                except:
                    pass
    True

def g(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i+1][j-1]==fe1[i+1][j]=="1":
                        print "G"
                        return False
                except:
                    pass
    return True

if __name__ == "__main__":
    inp()

Submission status: Wrong Answer

Solution code:
#encoding=utf-8
import sys

def inp():
    fe, fe1,count = [], [], 0
    for line in sys.stdin:
        fe += line.split()
        count += 1
        if count%9 ==0:
            a(fe)
            fe = []
    a(fe)

def a(fe1):
    for i in xrange(8):
        for j in xrange(8):
            if fe1[i][j] == "1":
                try:
                    if fe1[i][j+1]==fe1[i+1][j]==fe1[i+1][j+1]=="1": print "A"
                    if fe1[i+1][j]==fe1[i+2][j]==fe1[i+3][j]=="1": print "B"
                    if fe1[i][j+1]==fe1[i][j+2]==fe1[i][j+3]=="1": print "C"
                    if fe1[i+1][j-1]==fe1[i+1][j]==fe1[i+2][j-1]=="1": print "D"
                    if fe1[i][j+1]==fe1[i+1][j+1]==fe1[i+1][j+2]=="1": print "E"
                    if fe1[i+1][j]==fe1[i+1][j+1]==fe1[i+2][j+1]=="1": print "F"
                    if fe1[i][j+1]==fe1[i+1][j-1]==fe1[i+1][j]=="1": print "G"
                except: pass

if __name__ == "__main__":
    inp()

Submission status: Wrong Answer

Solution code:
def block(b):
    for i in range(8):
        for j in range(8):
            if b[i][j] == 1:
                if sum(b[i]) == 4:
                    return 'C'
                if sum(b[j]) == 4:
                    return 'B'
                if sum(b[i]) == 2:
                    if b[i + 1][j] == 0:
                        return 'E'
                    if b[i + 1][j + 1] == 0:
                        return 'G'
                    return 'A'
                if j > 0 and b[i + 1][j - 1] == 1:
                    return 'D'
                return 'F'

while True:
    try:
        b = 8 * [8 * [0]]
        for i in range(8):
            b[i] = list(map(int, input()))
        print(block(b))
        input()
    except:
        break

Submission status: Wrong Answer

Solution code:
while 1:
	try:
		pos=[]
		for i in xrange(8):
			s=raw_input()
			for j in xrange(8):
				if int(s[j])==1:
					pos.append([i,j])
		if pos[0][0]+1==pos[3][0] and pos[0][1]+1==pos[3][1]:
			print('A')
		elif pos[0][0]+3==pos[3][0]:
			print('B')
		elif pos[0][1]+3==pos[3][1]:
			print('C')
		elif pos[0][1]==pos[3][1]-1:
			print('D')
		elif pos[0][0]+1==pos[3][0] and pos[0][1]+2==pos[3][1]:
			print('E')
		else:
			print('F')
		raw_input()
	except:
		break

Submission status: Wrong Answer

Solution code:
while 1:
	try:
		pos=[]
		for i in xrange(8):
			s=raw_input()
			for j in xrange(8):
				if int(s[j])==1:
					pos.append([i,j])
		print pos
		if pos[0][0]+1==pos[3][0] and pos[0][1]+1==pos[3][1]:
			print('A')
		elif pos[0][0]+3==pos[3][0]:
			print('B')
		elif pos[0][1]+3==pos[3][1]:
			print('C')
		elif pos[0][1]==pos[3][1]+1:
			print('D')
		elif pos[0][0]+1==pos[3][0] and pos[0][1]+2==pos[3][1]:
			print('E')
		else:
			print('F')
		raw_input()
	except:
		break

Submission status: Wrong Answer

Solution code:
while 1:
	try:
		pos=[]
		for i in xrange(8):
			s=raw_input()
			for j in xrange(8):
				if int(s[j])==1:
					pos.append([i,j])
		if pos[0][0]+1==pos[3][0] and pos[0][1]+1==pos[3][1]:
			print('A')
		elif pos[0][0]+3==pos[3][0]:
			print('B')
		elif pos[0][1]+3==pos[3][1]:
			print('C')
		elif pos[0][1]==pos[3][1]+1:
			print('D')
		elif pos[0][0]+1==pos[3][0] and pos[0][1]+2==pos[3][1]:
			print('E')
		else:
			print('F')
		raw_input()
	except:
		break

Submission status: Wrong Answer

Solution code:
maxl = 8

offsetV = ('A', 'B', 'C', 'D', 'E', 'F', 'G')
offset = (((0, 1), (1, 0), (1, 1)),
          ((0, 1), (0, 2), (0, 3)),
          ((1, 0), (2, 0), (3, 0)),
          ((0, 1), (-1, 1), (-1, 2)),
          ((1, 0), (1, 1), (2, 1)),
          ((0, 1), (1, 1), (1, 2)),
          ((1, 0), (-1, 1), (0, 1)),
          )


def match(l, x, y, oi):
    for offX, offY in [a for a in offset[oi]]:
        if 0 <= x + offX  <= maxl and 0 <= y + offY < maxl:
            pass
        else:
            return False

        if l[y + offY][x + offX] == '0':
            return False
    return True


def solve():
    l = [input() for i in range(9)]
    for y in range(7):
        for x in range(7):
            if l[y][x] == '1':
                for o in range(7):
                    if match(l, x, y, o):
                        return offsetV[o]



try:
    while 1:
        print(solve())
except:
    pass

Submission status: Wrong Answer

Solution code:
maxl = 8

offsetV = ('A', 'B', 'C', 'D', 'E', 'F', 'G')
offset = (((0, 1), (1, 0), (1, 1)),
          ((0, 1), (0, 2), (0, 3)),
          ((1, 0), (2, 0), (3, 0)),
          ((0, 1), (-1, 1), (-1, 2)),
          ((1, 0), (1, 1), (2, 1)),
          ((0, 1), (1, 1), (1, 2)),
          ((1, 0), (-1, 1), (0, 1)),
          )


def match(l, x, y, oi):
    for offX, offY in [a for a in offset[oi]]:
        if 0 <= x + offX <= maxl and 0 <= y + offY < maxl:
            pass
        else:
            return False

        if l[y + offY][x + offX] == '0':
            return False
    return True


def solve():
    l = [input() for i in range(9)]
    for y in range(8):
        for x in range(8):
            if l[y][x] == '1':
                for o in range(7):
                    if match(l, x, y, o):
                        return offsetV[o]



try:
    while 1:
        print(solve())
except:
    pass

Submission status: Wrong Answer

Solution code:
import sys
s=[]
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
for line in sys.stdin:
	if line!="":
		s.append(line)
	else:
		while s[0]=="00000000":
			del s[0]
		while s[len(s)-1]=="00000000":
			del s[len(s)-1]
		i=0
		while i<len(s[0]):
			for l in s:
				if l[i]=="1":
					break
			else:
				for l in range(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
				i-=1
			i+=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])

Submission status: Wrong Answer

Solution code:
while True:
    try:
        Map = []
        Base = []
        End = []
        for i in range(8):
            Map.append(list(map(str,input())))
        for i in range(8):
            if Base == []:
                
                for j in range(8):
                    if Map[i][j] == '1':
                        Base = [j,i]
                        break
            else:
                break
        for i in range(7,-1,-1):
            if End == []:
                for j in range(7,-1,-1):
                    if Map[i][j] == '1':
                        End = [j,i]
                        break
            else:
                break
        Yoko = End[0] - Base[0]
        Tate = End[1] - Base[1]
        if Tate == 1 and Yoko == 1:
            print("A")
        elif Yoko == 0 and Tate == 3:
            print("B")
        elif Tate == 0 and Yoko == 3:
            print("C")
        elif Yoko == -1 and Tate == 2:
            print("D")
        elif Yoko == 2 and Tate == 1:
            print("E")
        elif Yoko == 1 and Tate == 2:
            print("F")
        elif Tate == 1 and Yoko == 0:
            print("G")
        kara = input()
            
    except (EOFError,IndexError):
        print(Map)
        break

Submission status: Wrong Answer

Solution code:
import sys


def analyze_figure(data):
    """
    ??????????????????????????§?????????????????£???????????????'1'????????£?????????????????¢??????
    ??????????????¨????????¶??????????????¢??????????????????
    """
    for i, row in enumerate(data):
        if '1' not in row:
            continue
        dot = row.count('1')
        if dot == 1:  # B, D, F???????????????
            x = row.index('1')
            try:
                if data[i+2][x] == '1':
                    return 'B'
                elif data[i+1][x+1] == '1':
                    return 'F'
                else:
                    return 'D'
            except IndexError:
                return None
        else:  # A, C, E, G???????????????
            x = row.index('1')
            try:
                if data[i][x+2] == '1':
                    return 'C'
                elif data[i+1][x] == '0':
                    return 'E'
                elif data[i+1][x+1] == '1':
                    return 'A'
                else:
                    return 'G'
            except IndexError:
                return None


if __name__ == '__main__':
    data = []
    for line in sys.stdin:
        if '0' in line or '1' in line:
            data.append(line.strip())
            continue
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')

        # ???????????????
        ans = analyze_figure(data)

        # ???????????¨???
        if ans:
            print(ans)
        data = []