Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>
#include <deque>
#include <cmath>
#include <stack>
#include <ctime>
#include <queue>
#include <set>
#include <map>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
#define X first
#define Y second
#define MP make_pair
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
 
const int ppr[] = {257, 263};
const ll INF = 2e18;
const int inf = 2e9;
const int mod[] = {int(1e9 + 7), int(1e9 + 9)};
const int N = 1e6 + 123;
const ld pi = 3.141592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

ll n, a, b, c, m, u[N], d[N], timer;

void upd(ll mask, ll x) {
	if(u[mask] == timer) return;
	u[mask] = timer;
	d[mask] = min(d[mask], x);
	for(ll i = 0; i < n; i++)
		if(mask & (1<<i))
			upd((mask^(1<<i)), x);
}

main() {             	
//  freopen(".in", "r", stdin);                          
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));
	
	speed;

	cin >> n >> m;

	for(ll i = 0; i < (1<<n); i++)
		d[i] = INF;

	for(ll i = 1; i <= m; i++) {
		ll mask = 0;
		cin >> a >> b;
		while(b--) {
			cin >> c;
			c--;
			mask ^= (1<<c);
		}
		timer++;
		upd(mask, a);
	}

	ll mn = inf;
	for(ll i = 0; i < (1<<n); i++)
		mn = min(mn, d[i] + d[i ^ ((1<<n) - 1)]);
	if(mn == inf) mn = -1;
	cout << mn;

    return 0;
}  #include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>
#include <deque>
#include <cmath>
#include <stack>
#include <ctime>
#include <queue>
#include <set>
#include <map>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
#define X first
#define Y second
#define MP make_pair
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
 
const int ppr[] = {257, 263};
const ll INF = 2e18;
const int inf = 2e9;
const int mod[] = {int(1e9 + 7), int(1e9 + 9)};
const int N = 1e6 + 123;
const ld pi = 3.141592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

ll n, a, b, c, m, u[N], d[N], timer;

void upd(ll mask, ll x) {
	if(u[mask] == timer) return;
	u[mask] = timer;
	d[mask] = min(d[mask], x);
	for(ll i = 0; i < n; i++)
		if(mask & (1<<i))
			upd((mask^(1<<i)), x);
}

main() {             	
//  freopen(".in", "r", stdin);                          
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));
	
	speed;

	cin >> n >> m;

	for(ll i = 0; i < (1<<n); i++)
		d[i] = INF;

	for(ll i = 1; i <= m; i++) {
		ll mask = 0;
		cin >> a >> b;
		while(b--) {
			cin >> c;
			c--;
			mask ^= (1<<c);
		}
		timer++;
		upd(mask, a);
	}

	ll mn = inf;
	for(ll i = 0; i < (1<<n); i++)
		mn = min(mn, d[i] + d[i ^ ((1<<n) - 1)]);
	if(mn == inf) mn = -1;
	cout << mn;

    return 0;
}  

Compiler output:
a.cc:113:4: error: stray '#' in program
  113 | }  #include <algorithm>
      |    ^
a.cc:81:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   81 | main() {
      | ^~~~
a.cc:113:5: error: 'include' does not name a type
  113 | }  #include <algorithm>
      |     ^~~~~~~
a.cc:170:11: error: redefinition of 'll bip(ll, ll, ll)'
  170 | inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
      |           ^~~
a.cc:58:11: note: 'll bip(ll, ll, ll)' previously defined here
   58 | inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
      |           ^~~
a.cc:172:11: error: redefinition of 'const int ppr []'
  172 | const int ppr[] = {257, 263};
      |           ^~~
a.cc:60:11: note: 'const int ppr [2]' previously defined here
   60 | const int ppr[] = {257, 263};
      |           ^~~
a.cc:173:10: error: redefinition of 'const ll INF'
  173 | const ll INF = 2e18;
      |          ^~~
a.cc:61:10: note: 'const ll INF' previously defined here
   61 | const ll INF = 2e18;
      |          ^~~
a.cc:174:11: error: redefinition of 'const int inf'
  174 | const int inf = 2e9;
      |           ^~~
a.cc:62:11: note: 'const int inf' previously defined here
   62 | const int inf = 2e9;
      |           ^~~
a.cc:175:11: error: redefinition of 'const int mod []'
  175 | const int mod[] = {int(1e9 + 7), int(1e9 + 9)};
      |           ^~~
a.cc:63:11: note: 'const int mod [2]' previously defined here
   63 | const int mod[] = {int(1e9 + 7), int(1e9 + 9)};
      |           ^~~
a.cc:176:11: error: redefinition of 'const int N'
  176 | const int N = 1e6 + 123;
      |           ^
a.cc:64:11: note: 'const int N' previously defined here
   64 | const int N = 1e6 + 123;
      |           ^
a.cc:177:10: error: redefinition of 'const ld pi'
  177 | const ld pi = 3.141592653589793238462643;
      |          ^~
a.cc:65:10: note: 'const ld pi' previously defined here
   65 | const ld pi = 3.141592653589793238462643;
      |          ^~
a.cc:179:11: error: redefinition of 'const int dx []'
  179 | const int dx[] = {1, 0, -1, 0};
      |           ^~
a.cc:67:11: note: 'const int dx [4]' previously defined here
   67 | const int dx[] = {1, 0, -1, 0};
      |           ^~
a.cc:180:11: error: redefinition of 'const int dy []'
  180 | const int dy[] = {0, 1, 0, -1};
      |           ^~
a.cc:68:11: note: 'const int dy [4]' previously defined here
   68 | const int dy[] = {0, 1, 0, -1};
      |           ^~
a.cc:182:4: error: redefinition of 'll n'
  182 | ll n, a, b, c, m, u[N], d[N], timer;
      |    ^
a.cc:70:4: note: 'll n' previously declared here
   70 | ll n, a, b, c, m, u[N], d[N], timer;
      |    ^
a.cc:182:7: error: redefinition of 'll a'
  182 | ll n, a, b, c, m, u[N], d[N], timer;
      |       ^
a.cc:70:7: note: 'll a' previously declared here
   70 | ll n, a, b, c, m, u[N], d[N], timer;
      |       ^
a.cc:182:10: error: redefinition of 'll b'
  182 | ll n, a, b, c, m, u[N], d[N], timer;
      |          ^
a.cc:70:10: note: 'll b' previously declared here
   70 | ll n, a, b, c, m, u[N], d[N], timer;
      |          ^
a.cc:182:13: error: redefinition of 'll c'
  182 | ll n, a, b, c, m, u[N], d[N], timer;
      |             ^
a.cc:70:13: note: 'll c' previously declared here
   70 | ll n, a, b, c, m, u[N], d[N], timer;
      |             ^
a.cc:182:16: error: redefinition of 'll m'
  182 | ll n, a, b, c, m, u[N], d[N], timer;
      |                ^
a.cc:70:16: note: 'll m' previously declared here
   70 | ll n, a, b, c, m, u[N], d[N], timer;
      |                ^
a.cc:182:19: error: redefinition of 'll u [1000123]'
  182 | ll n, a, b, c, m, u[N], d[N], timer;
      |                   ^
a.cc:70:19: note: 'll u [1000123]' previously declared here
   70 | ll n, a, b, c, m, u[N], d[N], timer;
      |                   ^
a.cc:182:25: error: redefinition of 'll d [1000123]'
  182 | ll n, a, b, c, m, u[N], d[N], timer;
      |                         ^
a.cc:70:25: note: 'll d [1000123]' previously declared here
   70 | ll n, a, b, c, m, u[N], d[N], timer;
      |                         ^
a.cc:182:31: error: redefinition of 'll timer'
  182 | ll n, a, b, c, m, u[N], d[N], timer;
      |                               ^~~~~
a.cc:70:31: note: 'll timer' previously declared here
   70 | ll n, a, b, c, m, u[N], d[N], timer;
      |                               ^~~~~
a.cc:184:6: error: redefinition of 'void upd(ll, ll)'
  184 | void upd(ll mask, ll x) {
      |      ^~~
a.cc:72:6: note: 'void upd(ll, ll)' previously defined here
   72 | void upd(ll mask, ll x) {
      |      ^~~
a.cc:193:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  193 | main() {
      | ^~~~
a.cc:193:1: error: redefinition of 'int main()'
a.cc:81:1: note: 'int main()' previously defined here
   81 | main() {
      | ^~~~