import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    A = [0] * M
    C = [0] * M
    for i in range(M):
        A[i], b = map(int, readline().split())
        C[i] = sum(1 << (int(s) - 1) for s in readline().split())

    dp = [INF] * (1 << N)
    dp[0] = 0
    for S in range(1 << N):
        if dp[S] == INF:
            continue
        for a, c in zip(A, C):
            if dp[S | c] > dp[S] + a:
                dp[S | c] = dp[S] + a

    ans = dp[(1 << N) - 1]
    if ans < INF:
        print(ans)
    else:
        print(-1)
    return


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    N, M = map(int, readline().split())
    A = [0] * M
    C = [0] * M
    for i in range(M):
        A[i], b = map(int, readline().split())
        C[i] = sum(1 << (int(s) - 1) for s in readline().split())

    dp = [INF] * (1 << N)
    dp[0] = 0
    for S in range(1 << N):
        if dp[S] == INF:
            continue
        for a, c in zip(A, C):
            if dp[S | c] > dp[S] + a:
                dp[S | c] = dp[S] + a

    ans = dp[(1 << N) - 1]
    if ans < INF:
        print(ans)
    else:
        print(-1)
    return main N, M = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split M A = [0] * M A [0] * M [0] 0 M C = [0] * M C [0] * M [0] 0 M for i in range(M):
        A[i], b = map(int, readline().split())
        C[i] = sum(1 << (int(s) - 1) for s in readline().split())

     i range(M) range M A[i], b = map(int, readline().split()) A[i] A i map(int, readline().split()) map int readline().split() ().split () readline split b C[i] = sum(1 << (int(s) - 1) for s in readline().split()) C[i] C i sum(1 << (int(s) - 1) for s in readline().split()) sum 1 << (int(s) - 1) 1 int(s) - 1 int(s) int s 1 dp = [INF] * (1 << N) dp [INF] * (1 << N) [INF] INF 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for S in range(1 << N):
        if dp[S] == INF:
            continue
        for a, c in zip(A, C):
            if dp[S | c] > dp[S] + a:
                dp[S | c] = dp[S] + a

     S range(1 << N) range 1 << N 1 N if dp[S] == INF:
            continue
         dp[S] == INF dp[S] dp S INF continue for a, c in zip(A, C):
            if dp[S | c] > dp[S] + a:
                dp[S | c] = dp[S] + a

     a c zip(A, C) zip A C if dp[S | c] > dp[S] + a:
                dp[S | c] = dp[S] + a

     dp[S | c] > dp[S] + a dp[S | c] dp S | c S c dp[S] + a dp[S] dp S a dp[S | c] = dp[S] + a dp[S | c] dp S | c S c dp[S] + a dp[S] dp S a ans = dp[(1 << N) - 1] ans dp[(1 << N) - 1] dp (1 << N) - 1 1 << N 1 N 1 if ans < INF:
        print(ans)
    else:
        print(-1)
     ans < INF ans INF print(ans) print ans print(-1) print -1 return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.readline sys.stdin.readline readline readlines = sys.stdin.readlines sys.stdin.readlines readlines def main():
    N, M = map(int, readline().split())
    A = [0] * M
    C = [0] * M
    for i in range(M):
        A[i], b = map(int, readline().split())
        C[i] = sum(1 << (int(s) - 1) for s in readline().split())

    dp = [INF] * (1 << N)
    dp[0] = 0
    for S in range(1 << N):
        if dp[S] == INF:
            continue
        for a, c in zip(A, C):
            if dp[S | c] > dp[S] + a:
                dp[S | c] = dp[S] + a

    ans = dp[(1 << N) - 1]
    if ans < INF:
        print(ans)
    else:
        print(-1)
    return def main():
    N, M = map(int, readline().split())
    A = [0] * M
    C = [0] * M
    for i in range(M):
        A[i], b = map(int, readline().split())
        C[i] = sum(1 << (int(s) - 1) for s in readline().split())

    dp = [INF] * (1 << N)
    dp[0] = 0
    for S in range(1 << N):
        if dp[S] == INF:
            continue
        for a, c in zip(A, C):
            if dp[S | c] > dp[S] + a:
                dp[S | c] = dp[S] + a

    ans = dp[(1 << N) - 1]
    if ans < INF:
        print(ans)
    else:
        print(-1)
    return main MOD = 1000000007 1000000007 MOD INF = 1 << 60 1 << 60 INF read = sys.stdin.read sys.stdin.read read
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    A = [0] * M
    C = [0] * M
    for i in range(M):
        A[i], b = map(int, readline().split())
        C[i] = sum(1 << (int(s) - 1) for s in readline().split())

    dp = [INF] * (1 << N)
    dp[0] = 0
    for S in range(1 << N):
        if dp[S] == INF:
            continue
        for a, c in zip(A, C):
            if dp[S | c] > dp[S] + a:
                dp[S | c] = dp[S] + a

    ans = dp[(1 << N) - 1]
    if ans < INF:
        print(ans)
    else:
        print(-1)
    return


if __name__ == '__main__':
    main()
