#include <bits/stdc++.h>
#define pi acos(-1)
#define sz(x) (int) x.size()
#define pii pair<int, int>
#define pill pair<int, long long>
#define mii map<int, int>
#define vi vector<int>
#define vll vector<long long>
#define vs vector<string>
#define vb vector<bool>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define popb pop_back
#define all(v) v.begin(),v.end()
#define mset(v, x) memset(v, x, sizeof(v))
#define mset2d(v, x, n) memset(v, x, sizeof(v[0][0]) * n * n)
#define mset2dd(v, x, n, m) memset(v, x, sizeof(v[0][0]) * n * m)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define debug2(x,y) cerr<<#x<<" : "<<x<<" & "<<#y<<" : "<<y<<endl
#define test() cerr<<"hola papa"<<endl
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
int n, t, s;
ll x;
void show(vll v) {
debug(sz(v));
for (int i = 0; i < sz(v); ++i) {
debug(v[i]);
}
}
vll shared(vector< vll > v) {
map<ll, int> m;
map<ll, int>::iterator it;
vll ans;
int li = sz(v);
if (li == 0) {
return ans;
}
int minsz = sz(v[0]);
int minidx = 0;
sort(all(v[minidx]));
for (int i = 1; i < li; ++i) {
sort(all(v[i]));
if (sz(v[i]) < minsz) minsz = sz(v[i]), minidx = i;
}
for (int i = 0; i < sz(v[minidx]); ++i) {
if (!m[v[minidx][i]]) {
m[v[minidx][i]] = 1;
}
}
for (it = m.begin(); it != m.end(); ++it) {
bool found = true;
for (int i = 0; i < li; ++i) {
if (i != minidx) {
found = binary_search(all(v[i]), it->fi);
if (!found) {
break;
}
}
}
if (found) {
ans.pb(it->fi);
}
}
return ans;
}
vll join(vector< vll > v) {
map<ll, int> m;
vll ans;
int li = sz(v);
for (int i = 0; i < li; ++i) {
int lj = sz(v[i]);
for (int j = 0; j < lj; ++j) {
if (!m[v[i][j]]) {
m[v[i][j]] = 1;
ans.pb(v[i][j]);
}
}
}
return ans;
}
int main() {
cin >> n;
vector< vll > vl;
vector< vll > vh;
for (int i = 0; i < n; ++i) {
vll v;
cin >> t >> s;
for (int j = 0; j < s; ++j) {
cin >> x;
v.pb(x);
}
t == 1 ? vl.pb(v) : vh.pb(v);
}
vll dlike = shared(vl);
vll hate = join(vh);
vector< vll > a;
a.pb(dlike), a.pb(hate);
vll u = join(a);
cout << sz(u) - sz(hate) << "\n";
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcGkgYWNvcygtMSkKI2RlZmluZSBzeih4KSAoaW50KSB4LnNpemUoKQojZGVmaW5lIHBpaSBwYWlyPGludCwgaW50PgojZGVmaW5lIHBpbGwgcGFpcjxpbnQsIGxvbmcgbG9uZz4KI2RlZmluZSBtaWkgbWFwPGludCwgaW50PgojZGVmaW5lIHZpIHZlY3RvcjxpbnQ+CiNkZWZpbmUgdmxsIHZlY3Rvcjxsb25nIGxvbmc+CiNkZWZpbmUgdnMgdmVjdG9yPHN0cmluZz4KI2RlZmluZSB2YiB2ZWN0b3I8Ym9vbD4KI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIHBvcGIgcG9wX2JhY2sKI2RlZmluZSBhbGwodikgdi5iZWdpbigpLHYuZW5kKCkKI2RlZmluZSBtc2V0KHYsIHgpIG1lbXNldCh2LCB4LCBzaXplb2YodikpCiNkZWZpbmUgbXNldDJkKHYsIHgsIG4pIG1lbXNldCh2LCB4LCBzaXplb2YodlswXVswXSkgKiBuICogbikKI2RlZmluZSBtc2V0MmRkKHYsIHgsIG4sIG0pIG1lbXNldCh2LCB4LCBzaXplb2YodlswXVswXSkgKiBuICogbSkKI2RlZmluZSBkZWJ1Zyh4KSBjZXJyPDwjeDw8IiA6ICI8PHg8PGVuZGwKI2RlZmluZSBkZWJ1ZzIoeCx5KSBjZXJyPDwjeDw8IiA6ICI8PHg8PCIgJiAiPDwjeTw8IiA6ICI8PHk8PGVuZGwKI2RlZmluZS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gaSA9IDA7IGkgPCBsaTsgKytpKSB7CiAgICAgICAgICAgIGlmIChpICE9IG1pbmlkeCkgewogICAgICAgICAgICAgICAgZm91bmQgPSBiaW5hcnlfc2VhcmNoKGFsbCh2W2ldKSwgaXQtPmZpKTsKCiAgICAgICAgICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGlmIChmb3VuZCkgewogICAgICAgICAgICBhbnMucGIoaXQtPmZpKTsKICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIGFuczsKfQoKdmxsIGpvaW4odmVjdG9yPCB2bGwgPiB2KSB7CiAgICBtYXA8bGwsIGludD4gbTsKICAgIHZsbCBhbnM7CgogICAgaW50IGxpID0gc3oodik7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBsaTsgKytpKSB7CiAgICAgICAgaW50IGxqID0gc3oodltpXSk7CgogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgbGo7ICsraikgewogICAgICAgICAgICBpZiAoIW1bdltpXVtqXV0pIHsKICAgICAgICAgICAgICAgIG1bdltpXVtqXV0gPSAxOwogICAgICAgICAgICAgICAgYW5zLnBiKHZbaV1bal0pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIHJldHVybiBhbnM7Cn0KCmludCBtYWluKCkgewogICAgY2luID4+IG47CgogICAgdmVjdG9yPCB2bGwgPiB2bDsKICAgIHZlY3RvcjwgdmxsID4gdmg7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgICB2bGwgdjsKICAgICAgICBjaW4gPj4gdCA+PiBzOwoKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IHM7ICsraikgewogICAgICAgICAgICBjaW4gPj4geDsKICAgICAgICAgICAgdi5wYih4KTsKICAgICAgICB9CgogICAgICAgIHQgPT0gMSA/IHZsLnBiKHYpIDogdmgucGIodik7CiAgICB9CiAgICAKICAgIHZsbCBkbGlrZSA9IHNoYXJlZCh2bCk7CiAgICB2bGwgaGF0ZSA9IGpvaW4odmgpOwoKICAgIHZlY3RvcjwgdmxsID4gYTsKICAgIGEucGIoZGxpa2UpLCBhLnBiKGhhdGUpOwoKICAgIHZsbCB1ID0gam9pbihhKTsKCiAgICBjb3V0IDw8IHN6KHUpIC0gc3ooaGF0ZSkgPDwgIlxuIjsKfQ==