#!/usr/bin/env python3
# -*- coding: utf-8 -*-

input_file = open("input.txt", "r")

left = []
right = []

for line in input_file:
    a, b = line.split()
    left.append(int(a))
    right.append(int(b))
input_file.close()

print(left)
print(right)

list_similarity = 0
for i in range(len(left)):
    list_similarity += right.count(left[i]) * left[i]

print(f'List-Similarity: {list_similarity}')