from sys import stdin, setrecursionlimit


def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    dp = [[INF] * (1 << n) for _ in range(m)]

    for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))

        dp[i][0] = 0

        tmp = 0
        for ci in c:
            tmp |= 1 << (ci - 1)

        if i == 0:
            dp[i][tmp] = a
        else:
            for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

    ans = dp[m - 1][-1]
    if ans == INF:
        print(-1)
    else:
        print(dp[m - 1][-1])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main() from sys import stdin, setrecursionlimit def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    dp = [[INF] * (1 << n) for _ in range(m)]

    for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))

        dp[i][0] = 0

        tmp = 0
        for ci in c:
            tmp |= 1 << (ci - 1)

        if i == 0:
            dp[i][tmp] = a
        else:
            for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

    ans = dp[m - 1][-1]
    if ans == INF:
        print(-1)
    else:
        print(dp[m - 1][-1]) main INF = float('inf') INF float('inf') float 'inf' input = stdin.buffer.readline input stdin.buffer.readline stdin.buffer stdin buffer readline n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m [INF] * (1 << n) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [INF] * (1 << n) [INF] INF 1 << n 1 n dp = [[INF] * (1 << n) for _ in range(m)] dp [[INF] * (1 << n) for _ in range(m)] for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))

        dp[i][0] = 0

        tmp = 0
        for ci in c:
            tmp |= 1 << (ci - 1)

        if i == 0:
            dp[i][tmp] = a
        else:
            for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

     i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dp[i][0] = 0 dp[i][0] [i] dp i 0 0 tmp = 0 tmp 0 for ci in c:
            tmp |= 1 << (ci - 1)

         ci c tmp |= 1 << (ci - 1) tmp 1 << (ci - 1) 1 ci - 1 ci 1 if i == 0:
            dp[i][tmp] = a
        else:
            for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

     i == 0 i 0 dp[i][tmp] = a dp[i][tmp] [i] dp i tmp a for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

     j range(1 << n) range 1 << n 1 n dp[i][j] = min(dp[i][j], dp[i - 1][j]) dp[i][j] [i] dp i j min(dp[i][j], dp[i - 1][j]) min dp[i][j] [i] dp i j dp[i - 1][j] [i - 1] dp i - 1 i 1 j dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a) dp[i][j | tmp] [i] dp i j | tmp j tmp min(dp[i][j | tmp], dp[i - 1][j] + a) min dp[i][j | tmp] [i] dp i j | tmp j tmp dp[i - 1][j] + a dp[i - 1][j] [i - 1] dp i - 1 i 1 j a ans = dp[m - 1][-1] ans dp[m - 1][-1] [m - 1] dp m - 1 m 1 -1 if ans == INF:
        print(-1)
    else:
        print(dp[m - 1][-1]) ans == INF ans INF print(-1) print -1 print(dp[m - 1][-1]) print dp[m - 1][-1] [m - 1] dp m - 1 m 1 -1 if __name__ == "__main__":
    setrecursionlimit(10000)
    main() __name__ == "__main__" __name__ "__main__" setrecursionlimit(10000) setrecursionlimit 10000 main() main def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    dp = [[INF] * (1 << n) for _ in range(m)]

    for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))

        dp[i][0] = 0

        tmp = 0
        for ci in c:
            tmp |= 1 << (ci - 1)

        if i == 0:
            dp[i][tmp] = a
        else:
            for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

    ans = dp[m - 1][-1]
    if ans == INF:
        print(-1)
    else:
        print(dp[m - 1][-1]) def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    dp = [[INF] * (1 << n) for _ in range(m)]

    for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))

        dp[i][0] = 0

        tmp = 0
        for ci in c:
            tmp |= 1 << (ci - 1)

        if i == 0:
            dp[i][tmp] = a
        else:
            for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

    ans = dp[m - 1][-1]
    if ans == INF:
        print(-1)
    else:
        print(dp[m - 1][-1]) main
from sys import stdin, setrecursionlimit


def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    dp = [[INF] * (1 << n) for _ in range(m)]

    for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))

        dp[i][0] = 0

        tmp = 0
        for ci in c:
            tmp |= 1 << (ci - 1)

        if i == 0:
            dp[i][tmp] = a
        else:
            for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

    ans = dp[m - 1][-1]
    if ans == INF:
        print(-1)
    else:
        print(dp[m - 1][-1])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
