def min2(x,y):
    return x if x < y else y

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

large = 1<<20
dp = [large]*(1<<N + 1)
dp[0] = 0
data = []
for i in range(M):
    a, b = map(int, input().split())
    bit = 0
    for c in map(int, input().split()):
        c -= 1
        bit = bit|1<<c
    data.append((a, bit))
for i, x in enumerate(data):
    a, bit = x
    for p in range(1<<N):
        dp[p|bit] = min2(dp[p] + a, dp[p|bit])
print(dp[(1<<N)-1] if dp[(1<<N)-1] != large else -1) def min2(x,y):
    return x if x < y else y min2 return x if x < y else y x if x < y else y x < y x y x y x x y y N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M large = 1<<20 large 1<<20 1 20 dp = [large]*(1<<N + 1) dp [large]*(1<<N + 1) [large] large 1<<N + 1 1 N + 1 N 1 dp[0] = 0 dp[0] dp 0 0 data = [] data [] for i in range(M):
    a, b = map(int, input().split())
    bit = 0
    for c in map(int, input().split()):
        c -= 1
        bit = bit|1<<c
    data.append((a, bit)) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b bit = 0 bit 0 for c in map(int, input().split()):
        c -= 1
        bit = bit|1<<c
     c map(int, input().split()) map int input().split() ().split () input split c -= 1 c 1 bit = bit|1<<c bit bit|1<<c bit 1<<c 1 c data.append((a, bit)) data.append data append (a, bit) a bit for i, x in enumerate(data):
    a, bit = x
    for p in range(1<<N):
        dp[p|bit] = min2(dp[p] + a, dp[p|bit]) i x enumerate(data) enumerate data a, bit = x a x bit for p in range(1<<N):
        dp[p|bit] = min2(dp[p] + a, dp[p|bit]) p range(1<<N) range 1<<N 1 N dp[p|bit] = min2(dp[p] + a, dp[p|bit]) dp[p|bit] dp p|bit p bit min2(dp[p] + a, dp[p|bit]) min2 dp[p] + a dp[p] dp p a dp[p|bit] dp p|bit p bit print(dp[(1<<N)-1] if dp[(1<<N)-1] != large else -1) print dp[(1<<N)-1] if dp[(1<<N)-1] != large else -1 dp[(1<<N)-1] != large dp[(1<<N)-1] dp (1<<N)-1 1<<N 1 N 1 large dp[(1<<N)-1] dp (1<<N)-1 1<<N 1 N 1 -1 data = [] [] data b = map(int, input().split()) map(int, input().split()) b dp = [large]*(1<<N + 1) [large]*(1<<N + 1) dp def min2(x,y):
    return x if x < y else y def min2(x,y):
    return x if x < y else y min2 a, b = map(int, input().split()) map(int, input().split()) a bit = x x bit bit = 0 0 bit N, M = map(int, input().split()) map(int, input().split()) N c -= 1 1 c M = map(int, input().split()) map(int, input().split()) M large = 1<<20 1<<20 large a, bit = x x a bit = bit|1<<c bit|1<<c bit
def min2(x,y):
    return x if x < y else y

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

large = 1<<20
dp = [large]*(1<<N + 1)
dp[0] = 0
data = []
for i in range(M):
    a, b = map(int, input().split())
    bit = 0
    for c in map(int, input().split()):
        c -= 1
        bit = bit|1<<c
    data.append((a, bit))
for i, x in enumerate(data):
    a, bit = x
    for p in range(1<<N):
        dp[p|bit] = min2(dp[p] + a, dp[p|bit])
print(dp[(1<<N)-1] if dp[(1<<N)-1] != large else -1)