import sys

def read_input(file):
    data = []
    with open(file, 'r') as f:
        data = f.readlines()
    n = int(data[0])
    points = [(int(line.split()[0]), int(line.split()[1])) for line in data[1:]]
    junk = [(0, 0)]
    points = junk + points
    return n, points

def read_output(file):
    data = []
    with open(file, 'r') as f:
        data = f.readlines()
    cost = int(data[0])
    path = [int(p) for p in data[1].split()]
    junk = [0]
    path = junk + path
    return cost, path

def manhattan_distance(p1, p2):
    return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1])

def calculate_cost(points, path, n):
    cost = 0
    cost += manhattan_distance(points[1], points[path[1]])
    cost += manhattan_distance(points[1], points[path[n - 1]])

    for i in range(1, n - 1):
        cost += manhattan_distance(points[path[i]], points[path[i + 1]])
    return cost

def check_solution(std_output_file, usr_output_file, input_file):
    n, points = read_input(input_file)
    
    std_cost = 0
    with open(std_output_file, "r") as f:
        std_cost = int(f.readlines()[0])
    
    usr_cost, usr_path = read_output(usr_output_file)

    if usr_cost != calculate_cost(points, usr_path, n):
      sys.stderr.write("The cost and path do not match.\n")
      print(0)
      return
    elif usr_cost > 2 * std_cost:
      print(0)
      return
    else:
      print(100)
      return

# print("100")
if __name__ == "__main__":
    check_solution('answer', 'user_out', 'input')

