#E

import sys

input=sys.stdin.readline



def main():

    n,m=list(map(int,input().split()))

    Cost=[0]*m

    Key=[0]*m

    for i in range(m):

        a,b=list(map(int,input().split()))

        C=tuple(map(int,input().split()))

        Cost[i]=a

        for c in C:

            Key[i]+=1<<(c-1)

    #print(Cost,Key)

    DP=[[float('inf')]*(1<<n) for _ in range(m+1)]

    for i,(c,k) in enumerate(zip(Cost,Key)):

        DP[i+1][k]=min(DP[i][k],c)

        for j in range(1,1<<n):

            DP[i+1][j]=min(DP[i][j],DP[i+1][j])

            DP[i+1][j|k]=min(DP[i+1][j|k],DP[i][j|k],DP[i][j]+c)

        #print(DP)

    print((-1 if DP[-1][-1]==float('inf') else DP[-1][-1]))



if __name__=='__main__':

    main()
import sys

input=sys.stdin.readline



def main():

    n,m=list(map(int,input().split()))

    Cost=[0]*m

    Key=[0]*m

    for i in range(m):

        a,b=list(map(int,input().split()))

        C=tuple(map(int,input().split()))

        Cost[i]=a

        for c in C:

            Key[i]+=1<<(c-1)

    DP=[[float('inf')]*(1<<n) for _ in range(m+1)]

    DP[0][0]=0

    for i,(c,k) in enumerate(zip(Cost,Key)):

        for j in range(1<<n):

            DP[i+1][j]=min(DP[i][j],DP[i+1][j])

            DP[i+1][j|k]=min(DP[i+1][j|k],DP[i][j]+c)

    print((-1 if DP[-1][-1]==float('inf') else DP[-1][-1]))



if __name__=='__main__':

    main()
# E
import sys

input = sys.stdin.readline


def main():
    n, m = list(map(int, input().split()))
    Cost = [0] * m
    Key = [0] * m
    for i in range(m):
        a, b = list(map(int, input().split()))
        C = tuple(map(int, input().split()))
        Cost[i] = a
        for c in C:
            Key[i] += 1 << (c - 1)
    # print(Cost,Key)
    DP = [[float("inf")] * (1 << n) for _ in range(m + 1)]
    for i, (c, k) in enumerate(zip(Cost, Key)):
        DP[i + 1][k] = min(DP[i][k], c)
        for j in range(1, 1 << n):
            DP[i + 1][j] = min(DP[i][j], DP[i + 1][j])
            DP[i + 1][j | k] = min(DP[i + 1][j | k], DP[i][j | k], DP[i][j] + c)
        # print(DP)
    print((-1 if DP[-1][-1] == float("inf") else DP[-1][-1]))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    n, m = list(map(int, input().split()))
    Cost = [0] * m
    Key = [0] * m
    for i in range(m):
        a, b = list(map(int, input().split()))
        C = tuple(map(int, input().split()))
        Cost[i] = a
        for c in C:
            Key[i] += 1 << (c - 1)
    DP = [[float("inf")] * (1 << n) for _ in range(m + 1)]
    DP[0][0] = 0
    for i, (c, k) in enumerate(zip(Cost, Key)):
        for j in range(1 << n):
            DP[i + 1][j] = min(DP[i][j], DP[i + 1][j])
            DP[i + 1][j | k] = min(DP[i + 1][j | k], DP[i][j] + c)
    print((-1 if DP[-1][-1] == float("inf") else DP[-1][-1]))


if __name__ == "__main__":
    main()

-# E -    # print(Cost,Key) +    DP[0][0] = 0 -        DP[i + 1][k] = min(DP[i][k], c) -        for j in range(1, 1 << n): +        for j in range(1 << n): -            DP[i + 1][j | k] = min(DP[i + 1][j | k], DP[i][j | k], DP[i][j] + c) -        # print(DP) +            DP[i + 1][j | k] = min(DP[i + 1][j | k], DP[i][j] + c)