import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n, m = map(int, input().split())
    price = [0]*m
    typesnum = [0]*m
    keybit=[0]*m
    for i in range(m):
        price[i], typesnum[i] = map(int, input().split())
        keybit[i] = sum(map(lambda x: 2**(int(x)-1), input().split()))
    dp = [10**9]*(1 << n)
    dp[0]=0
    for bit in range(1 << n):
        for i in range(m):
            dp[bit | keybit[i]] = min(dp[bit | keybit[i]], dp[bit]+price[i])
    if dp[-1] == 10**9:
        dp[-1] = -1
    print(dp[-1])


if __name__ == '__main__':
    main() import sys sys def input(): return sys.stdin.readline().rstrip() input def main():
    n, m = map(int, input().split())
    price = [0]*m
    typesnum = [0]*m
    keybit=[0]*m
    for i in range(m):
        price[i], typesnum[i] = map(int, input().split())
        keybit[i] = sum(map(lambda x: 2**(int(x)-1), input().split()))
    dp = [10**9]*(1 << n)
    dp[0]=0
    for bit in range(1 << n):
        for i in range(m):
            dp[bit | keybit[i]] = min(dp[bit | keybit[i]], dp[bit]+price[i])
    if dp[-1] == 10**9:
        dp[-1] = -1
    print(dp[-1]) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m price = [0]*m price [0]*m [0] 0 m typesnum = [0]*m typesnum [0]*m [0] 0 m keybit=[0]*m keybit [0]*m [0] 0 m for i in range(m):
        price[i], typesnum[i] = map(int, input().split())
        keybit[i] = sum(map(lambda x: 2**(int(x)-1), input().split()))
     i range(m) range m price[i], typesnum[i] = map(int, input().split()) price[i] price i map(int, input().split()) map int input().split() ().split () input split typesnum[i] typesnum i keybit[i] = sum(map(lambda x: 2**(int(x)-1), input().split())) keybit[i] keybit i sum(map(lambda x: 2**(int(x)-1), input().split())) sum map(lambda x: 2**(int(x)-1), input().split()) map lambda x: 2**(int(x)-1) 2**(int(x)-1) 2 int(x)-1 int(x) int x 1 x input().split() ().split () input split dp = [10**9]*(1 << n) dp [10**9]*(1 << n) [10**9] 10**9 10 9 1 << n 1 n dp[0]=0 dp[0] dp 0 0 for bit in range(1 << n):
        for i in range(m):
            dp[bit | keybit[i]] = min(dp[bit | keybit[i]], dp[bit]+price[i])
     bit range(1 << n) range 1 << n 1 n for i in range(m):
            dp[bit | keybit[i]] = min(dp[bit | keybit[i]], dp[bit]+price[i])
     i range(m) range m dp[bit | keybit[i]] = min(dp[bit | keybit[i]], dp[bit]+price[i]) dp[bit | keybit[i]] dp bit | keybit[i] bit keybit[i] keybit i min(dp[bit | keybit[i]], dp[bit]+price[i]) min dp[bit | keybit[i]] dp bit | keybit[i] bit keybit[i] keybit i dp[bit]+price[i] dp[bit] dp bit price[i] price i if dp[-1] == 10**9:
        dp[-1] = -1
     dp[-1] == 10**9 dp[-1] dp -1 10**9 10 9 dp[-1] = -1 dp[-1] dp -1 -1 print(dp[-1]) print dp[-1] dp -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n, m = map(int, input().split())
    price = [0]*m
    typesnum = [0]*m
    keybit=[0]*m
    for i in range(m):
        price[i], typesnum[i] = map(int, input().split())
        keybit[i] = sum(map(lambda x: 2**(int(x)-1), input().split()))
    dp = [10**9]*(1 << n)
    dp[0]=0
    for bit in range(1 << n):
        for i in range(m):
            dp[bit | keybit[i]] = min(dp[bit | keybit[i]], dp[bit]+price[i])
    if dp[-1] == 10**9:
        dp[-1] = -1
    print(dp[-1]) def main():
    n, m = map(int, input().split())
    price = [0]*m
    typesnum = [0]*m
    keybit=[0]*m
    for i in range(m):
        price[i], typesnum[i] = map(int, input().split())
        keybit[i] = sum(map(lambda x: 2**(int(x)-1), input().split()))
    dp = [10**9]*(1 << n)
    dp[0]=0
    for bit in range(1 << n):
        for i in range(m):
            dp[bit | keybit[i]] = min(dp[bit | keybit[i]], dp[bit]+price[i])
    if dp[-1] == 10**9:
        dp[-1] = -1
    print(dp[-1]) main def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n, m = map(int, input().split())
    price = [0]*m
    typesnum = [0]*m
    keybit=[0]*m
    for i in range(m):
        price[i], typesnum[i] = map(int, input().split())
        keybit[i] = sum(map(lambda x: 2**(int(x)-1), input().split()))
    dp = [10**9]*(1 << n)
    dp[0]=0
    for bit in range(1 << n):
        for i in range(m):
            dp[bit | keybit[i]] = min(dp[bit | keybit[i]], dp[bit]+price[i])
    if dp[-1] == 10**9:
        dp[-1] = -1
    print(dp[-1])


if __name__ == '__main__':
    main()