import sys
n=8 #共有8个城市
dcity={0: "A", 1: "B", 2: "C", 3: "D", 4: "E", 5: "F",6:"G", 7: "H"}
a=[[0 for i in range(n)]for j in range(n)]
for line in sys.stdin:
s=line.strip()
b=list(map(int, s.split()))
a[b[0]][b[1]]=b[2] #记录两个城市间的距离
q=[0]*200 #初始化队列
path=[0]*n #记录驾车方案
f=[False]*n
ans=[9999]*n
destination=7 #目的城市H的编号为7
head=tail=0
q[tail]=0
tail+=1
f[0]=True
ans[0]=0
while head<tail:
...
...
p=destination
s=""
while p!=0:
s=dcity[path[p]]+"->"+s
p=path[p]
s=s+dcity[destination]
print(s)
print(ans[destination])