# ABC142E - Get Everything

import sys

input = sys.stdin.readline



def main():

    N, M = list(map(int, input().split()))

    p = 1 << N

    dp = [float("inf")] * p

    dp[0] = 0

    for _ in range(M):

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

        x = sum(1 << (i - 1) for i in map(int, input().split()))

        for y in range(p):

            if dp[x | y] > dp[y] + a:

                dp[x | y] = dp[y] + a

    ans = dp[-1] if dp[-1] != float("inf") else -1

    print(ans)





if __name__ == "__main__":

    main()
# ABC142E - Get Everything

def main():

    N, M = list(map(int, input().split()))

    p = 1 << N

    dp = [float("inf")] * p

    dp[0] = 0

    for _ in range(M):

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

        x = sum(1 << (i - 1) for i in map(int, input().split()))

        for y in range(p):

            if dp[x | y] > dp[y] + a:

                dp[x | y] = dp[y] + a

    ans = dp[-1] if dp[-1] != float("inf") else -1

    print(ans)





if __name__ == "__main__":

    main()
# ABC142E - Get Everything
import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    p = 1 << N
    dp = [float("inf")] * p
    dp[0] = 0
    for _ in range(M):
        a, _ = list(map(int, input().split()))
        x = sum(1 << (i - 1) for i in map(int, input().split()))
        for y in range(p):
            if dp[x | y] > dp[y] + a:
                dp[x | y] = dp[y] + a
    ans = dp[-1] if dp[-1] != float("inf") else -1
    print(ans)


if __name__ == "__main__":
    main()

# ABC142E - Get Everything
def main():
    N, M = list(map(int, input().split()))
    p = 1 << N
    dp = [float("inf")] * p
    dp[0] = 0
    for _ in range(M):
        a, _ = list(map(int, input().split()))
        x = sum(1 << (i - 1) for i in map(int, input().split()))
        for y in range(p):
            if dp[x | y] > dp[y] + a:
                dp[x | y] = dp[y] + a
    ans = dp[-1] if dp[-1] != float("inf") else -1
    print(ans)


if __name__ == "__main__":
    main()

-import sys - -input = sys.stdin.readline - -