def extract_arguments(fh):
    datasets = []
    while True:
        line = fh.readline().strip()
        if line == '0 0 0 0 0':
            break
        n, m, s, g1, g2 = map(int, line.split())
        roads = []
        for _ in range(m):
            b1, b2, c = map(int, fh.readline().strip().split())
            roads.append((b1, b2, c))
        datasets.append((n, m, s, g1, g2, roads))
    return datasets

# if __name__ == "__main__":
#     input_path = sys.argv[1]
#     with open(input_path, 'r') as fh:
#         datasets = extract_arguments(fh)
#         for data in datasets:
#             process_dataset(data)