Buggy python submission (verdict: Runtime Error):
import sys

def warshall(n, matrix):
  for i in xrange(n):
    matrix[i][i] = 0
  for i in xrange(n):
    for j in xrange(n):
      for k in xrange(n):
        matrix[j][k] = min(matrix[j][k], matrix[j][i]+matrix[i][k])
  return matrix

def dijkstra(nodes, start, matrix):
  defnode = [False] * (nodes)
  cost = [sys.maxint] * (nodes)
  cost[start] = 0
  node = start
  counter = 0
  while True:
    counter += 1
    if counter == nodes or node == sys.maxint:
      return cost
    defnode[node] = True
    for i in xrange(nodes):
      if defnode[i]:
        continue
      if matrix[node][i] == sys.maxint:
        continue
      cost[i] = min(cost[i], cost[node]+matrix[node][i])
    minnode = sys.maxint
    mincost = sys.maxint
    for i in xrange(nodes):
      if defnode[i]:
        continue
      if cost[i] < mincost:
        minnode = i
        mincost = cost[i]
    node = minnode

while True:
  # N : number of towns
  # M : time limit
  # L : locations for freeze
  # K : number of roads
  # A : start
  # H : destination
  N,M,L,K,A,H = map(int, raw_input().split())
  if N==M==L==K==A==H==0: break
  if L == 0:
    l = []
  else:
    l = map(int, raw_input().split())
  matrix = [[1000000] * N for _ in xrange(N)]
  for _ in xrange(K):
    x,y,t = map(int, raw_input().split())
    matrix[x][y] = t
    matrix[y][x] = t
  costs = warshall(N, matrix)
  newmatrix = [[1000000] * (L+2) for _ in xrange(L+2)]
  nodes = []
  nodes.append(A)
  nodes.extend(l)
  nodes.append(H)
  for i in xrange(len(nodes)):
    for j in xrange(len(nodes)):
      newmatrix[i][j] = matrix[nodes[i]][nodes[j]]
      if newmatrix[i][j] > M:
        newmatrix[i][j] = 1000000
  newcosts = dijkstra(L+2, 0, newmatrix)
  cost = newcosts[L+1]
  if cost >= 1000000:
    print "Help!"
  else:
    if cost > M:
      print cost*2-M
    else:
      print cost

Fixed submission:
import sys
import heapq

class Dijkstra(object):
  # def dijkstra(self, adj, start, goal=None):
  def dijkstra(self, num, path, start, goal=None):
    # num = len(adj)
    dist = [sys.maxint] * num
    prev = [sys.maxint] * num
    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if dist[src] < prov_cost: continue
      if src not in path: continue
      for dest,cost in path[src]:
        if dist[dest] > dist[src] + cost:
          dist[dest] = dist[src] + cost
          heapq.heappush(q, (dist[dest], dest))
          prev[dest] = src
      # for dest in range(num):
      #   cost = adj[src][dest]
      #   if cost != sys.maxint and dist[dest] > dist[src] + cost:
      #     dist[dest] = dist[src] + cost
      #     heapq.heappush(q, (dist[dest], dest))
      #     prev[dest] = src
    if goal is not None:
      return self.get_path(goal, prev)
    else:
      return dist

  def get_path(self, goal, prev):
    path = [goal]
    dest = goal
    while prev[dest] != sys.maxint:
      path.append(prev[dest])
      dest = prev[dest]
    return list(reversed(path))

while True:
  N,M,L,K,A,H=map(int,raw_input().split())
  if N==0: break
  # t(n,t) : minimum cost to remain t times and reach town n
  Ls=map(int,raw_input().split())
  # edge=[[sys.maxint]*(N*(M+1)) for _ in xrange(N*(M+1))]
  edge={}
  for l in Ls:
    for i in xrange(M):
      edge[l*(M+1)+i]=[(l*(M+1)+i+1,1)]
  for _ in xrange(K):
    s,g,c=map(int,raw_input().split())
    for i in xrange(c,M+1):
      if s*(M+1)+i not in edge: edge[s*(M+1)+i]=[]
      if g*(M+1)+i not in edge: edge[g*(M+1)+i]=[]
      edge[s*(M+1)+i].append((g*(M+1)+i-c,c))
      edge[g*(M+1)+i].append((s*(M+1)+i-c,c))
  cost=Dijkstra().dijkstra(N*(M+1), edge, A*(M+1)+M)
  minCost=sys.maxint
  for i in xrange(M+1):
    minCost=min(minCost,cost[H*(M+1)+i])
  if minCost==sys.maxint: print "Help!"
  else: print minCost

Buggy python submission (verdict: Runtime Error):
import sys

def warshall(n, matrix):
  for i in xrange(n):
    matrix[i][i] = 0
  for i in xrange(n):
    for j in xrange(n):
      for k in xrange(n):
        matrix[j][k] = min(matrix[j][k], matrix[j][i]+matrix[i][k])
  return matrix

def dijkstra(nodes, start, matrix):
  defnode = [False] * (nodes)
  cost = [sys.maxint] * (nodes)
  cost[start] = 0
  node = start
  counter = 0
  while True:
    counter += 1
    if counter == nodes or node == sys.maxint:
      return cost
    defnode[node] = True
    for i in xrange(nodes):
      if defnode[i]:
        continue
      if matrix[node][i] == sys.maxint:
        continue
      cost[i] = min(cost[i], cost[node]+matrix[node][i])
    minnode = sys.maxint
    mincost = sys.maxint
    for i in xrange(nodes):
      if defnode[i]:
        continue
      if cost[i] < mincost:
        minnode = i
        mincost = cost[i]
    node = minnode

while True:
  # N : number of towns
  # M : time limit
  # L : locations for freeze
  # K : number of roads
  # A : start
  # H : destination
  N,M,L,K,A,H = map(int, raw_input().split())
  if N==M==L==K==A==H==0: break
  l = map(int, raw_input().split())
  matrix = [[1000000] * N for _ in xrange(N)]
  for _ in xrange(K):
    x,y,t = map(int, raw_input().split())
    matrix[x][y] = t
    matrix[y][x] = t
  costs = warshall(N, matrix)
  newmatrix = [[1000000] * (L+2) for _ in xrange(L+2)]
  nodes = []
  nodes.append(A)
  nodes.extend(l)
  nodes.append(H)
  for i in xrange(len(nodes)):
    for j in xrange(len(nodes)):
      newmatrix[i][j] = matrix[nodes[i]][nodes[j]]
      if newmatrix[i][j] > M:
        newmatrix[i][j] = 1000000
  newcosts = dijkstra(L+2, 0, newmatrix)
  cost = newcosts[L+1]
  if cost >= 1000000:
    print "Help!"
  else:
    if cost > M:
      print cost*2-M
    else:
      print cost

Fixed submission:
import sys
import heapq

class Dijkstra(object):
  # def dijkstra(self, adj, start, goal=None):
  def dijkstra(self, num, path, start, goal=None):
    # num = len(adj)
    dist = [sys.maxint] * num
    prev = [sys.maxint] * num
    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if dist[src] < prov_cost: continue
      if src not in path: continue
      for dest,cost in path[src]:
        if dist[dest] > dist[src] + cost:
          dist[dest] = dist[src] + cost
          heapq.heappush(q, (dist[dest], dest))
          prev[dest] = src
      # for dest in range(num):
      #   cost = adj[src][dest]
      #   if cost != sys.maxint and dist[dest] > dist[src] + cost:
      #     dist[dest] = dist[src] + cost
      #     heapq.heappush(q, (dist[dest], dest))
      #     prev[dest] = src
    if goal is not None:
      return self.get_path(goal, prev)
    else:
      return dist

  def get_path(self, goal, prev):
    path = [goal]
    dest = goal
    while prev[dest] != sys.maxint:
      path.append(prev[dest])
      dest = prev[dest]
    return list(reversed(path))

while True:
  N,M,L,K,A,H=map(int,raw_input().split())
  if N==0: break
  # t(n,t) : minimum cost to remain t times and reach town n
  Ls=map(int,raw_input().split())
  # edge=[[sys.maxint]*(N*(M+1)) for _ in xrange(N*(M+1))]
  edge={}
  for l in Ls:
    for i in xrange(M):
      edge[l*(M+1)+i]=[(l*(M+1)+i+1,1)]
  for _ in xrange(K):
    s,g,c=map(int,raw_input().split())
    for i in xrange(c,M+1):
      if s*(M+1)+i not in edge: edge[s*(M+1)+i]=[]
      if g*(M+1)+i not in edge: edge[g*(M+1)+i]=[]
      edge[s*(M+1)+i].append((g*(M+1)+i-c,c))
      edge[g*(M+1)+i].append((s*(M+1)+i-c,c))
  cost=Dijkstra().dijkstra(N*(M+1), edge, A*(M+1)+M)
  minCost=sys.maxint
  for i in xrange(M+1):
    minCost=min(minCost,cost[H*(M+1)+i])
  if minCost==sys.maxint: print "Help!"
  else: print minCost

Buggy python submission (verdict: Runtime Error):
import sys
import heapq

class Dijkstra(object):
  def dijkstra(self, adj, start, goal=None):
    num = len(adj)
    dist = [sys.maxint] * num
    prev = [sys.maxint] * num
    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if dist[src] < prov_cost: continue
      for dest in range(num):
        cost = adj[src][dest]
        if cost != sys.maxint and dist[dest] > dist[src] + cost:
          dist[dest] = dist[src] + cost
          heapq.heappush(q, (dist[dest], dest))
          prev[dest] = src
    if goal is not None:
      return self.get_path(goal, prev)
    else:
      return dist

  def get_path(self, goal, prev):
    path = [goal]
    dest = goal
    while prev[dest] != sys.maxint:
      path.append(prev[dest])
      dest = prev[dest]
    return list(reversed(path))

while True:
  N,M,L,K,A,H=map(int,raw_input().split())
  if N==0: break
  # t(n,t) : minimum cost to remain t times and reach town n
  if L==0:
    Ls=[]
  else:
    Ls=map(int,raw_input().split())
  edge=[[sys.maxint]*(N*(M+1)) for _ in xrange(N*(M+1))]
  for l in Ls:
    for i in xrange(M):
      edge[l*(M+1)+i][l*(M+1)+i+1]=1
  for _ in xrange(K):
    s,g,c=map(int,raw_input().split())
    for i in xrange(c,M+1):
      edge[s*(M+1)+i][g*(M+1)+i-c]=c
      edge[g*(M+1)+i][s*(M+1)+i-c]=c
  cost=Dijkstra().dijkstra(edge, A*(M+1)+M)
  minCost=sys.maxint
  for i in xrange(M+1):
    minCost=min(minCost,cost[H*(M+1)+i])
  if minCost==sys.maxint: print "Help!"
  else: print minCost

Fixed submission:
import sys
import heapq

class Dijkstra(object):
  # def dijkstra(self, adj, start, goal=None):
  def dijkstra(self, num, path, start, goal=None):
    # num = len(adj)
    dist = [sys.maxint] * num
    prev = [sys.maxint] * num
    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if dist[src] < prov_cost: continue
      if src not in path: continue
      for dest,cost in path[src]:
        if dist[dest] > dist[src] + cost:
          dist[dest] = dist[src] + cost
          heapq.heappush(q, (dist[dest], dest))
          prev[dest] = src
      # for dest in range(num):
      #   cost = adj[src][dest]
      #   if cost != sys.maxint and dist[dest] > dist[src] + cost:
      #     dist[dest] = dist[src] + cost
      #     heapq.heappush(q, (dist[dest], dest))
      #     prev[dest] = src
    if goal is not None:
      return self.get_path(goal, prev)
    else:
      return dist

  def get_path(self, goal, prev):
    path = [goal]
    dest = goal
    while prev[dest] != sys.maxint:
      path.append(prev[dest])
      dest = prev[dest]
    return list(reversed(path))

while True:
  N,M,L,K,A,H=map(int,raw_input().split())
  if N==0: break
  # t(n,t) : minimum cost to remain t times and reach town n
  Ls=map(int,raw_input().split())
  # edge=[[sys.maxint]*(N*(M+1)) for _ in xrange(N*(M+1))]
  edge={}
  for l in Ls:
    for i in xrange(M):
      edge[l*(M+1)+i]=[(l*(M+1)+i+1,1)]
  for _ in xrange(K):
    s,g,c=map(int,raw_input().split())
    for i in xrange(c,M+1):
      if s*(M+1)+i not in edge: edge[s*(M+1)+i]=[]
      if g*(M+1)+i not in edge: edge[g*(M+1)+i]=[]
      edge[s*(M+1)+i].append((g*(M+1)+i-c,c))
      edge[g*(M+1)+i].append((s*(M+1)+i-c,c))
  cost=Dijkstra().dijkstra(N*(M+1), edge, A*(M+1)+M)
  minCost=sys.maxint
  for i in xrange(M+1):
    minCost=min(minCost,cost[H*(M+1)+i])
  if minCost==sys.maxint: print "Help!"
  else: print minCost