Set Mutations

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