#C7760. Unique Flight Segment Distance

    ID: 51667 Type: Default 1000ms 256MiB

Unique Flight Segment Distance

Unique Flight Segment Distance

During the bird migration season, a bird traverses several flight segments. Each flight segment is represented by three integers: the starting marker, the ending marker, and the distance covered. Duplicate segments should be counted only once.

Your task is to compute the total distance traveled by summing the distances of each unique flight segment. In mathematical terms, if \(S\) is the set of unique segments \((u, v, d)\), you need to compute:

[ \text{Total} = \sum_{(u,v,d) \in S} d ]

Note: Two segments are considered the same if they have the identical starting marker, ending marker, and distance.

inputFormat

The input is given via stdin and has the following format:

 n
 a1 b1 d1
 a2 b2 d2
 ...
 an bn dn

Here, n is the number of flight segments. Each of the following n lines contains three space-separated integers where ai is the starting marker, bi is the ending marker, and di is the flight distance for that segment.

outputFormat

Output a single integer to stdout representing the total distance traveled by accumulating the distance of each unique flight segment.

## sample
4
1 2 100
2 3 150
3 4 200
1 2 100
450