Set Mutations

  • + 0 comments
    _ = int(input())
    a = set(map(int, input().split()))
    n = int(input())
    for _ in range(n):
        op, _ = input().split()
        b = set(map(int, input().split()))
        getattr(a, op)(b)
    print(sum(a))