#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;
int main() {
cin >> n;
vector< vll > vl;
vector< vll > vh;
map<ll, int> m;
map<ll, int>::iterator it;
for (int i = 0; i < n; ++i) {
vll v;
cin >> t >> s;
for (int j = 0; j < s; ++j) {
cin >> x;
v.pb(x);
m[x] = 0;
}
t == 1 ? vl.pb(v) : vh.pb(v);
}
for (int i = 0; i < sz(vl); ++i) {
for (int j = 0; j < sz(vl[i]); ++j) {
m[vl[i][j]]++;
}
}
for (int i = 0; i < sz(vh); ++i) {
for (int j = 0; j < sz(vh[j]); ++j) {
m[vh[i][j]] = -1;
}
}
int ans = 0;
for (it = m.begin(); it != m.end(); ++it) {
if (it->se == sz(vl)) {
++ans;
}
}
cout << ans << "\n";
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcGkgYWNvcygtMSkKI2RlZmluZSBzeih4KSAoaW50KSB4LnNpemUoKQojZGVmaW5lIHBpaSBwYWlyPGludCwgaW50PgojZGVmaW5lIHBpbGwgcGFpcjxpbnQsIGxvbmcgbG9uZz4KI2RlZmluZSBtaWkgbWFwPGludCwgaW50PgojZGVmaW5lIHZpIHZlY3RvcjxpbnQ+CiNkZWZpbmUgdmxsI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B2bGwgdjsKICAgICAgICBjaW4gPj4gdCA+PiBzOwoKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IHM7ICsraikgewogICAgICAgICAgICBjaW4gPj4geDsKICAgICAgICAgICAgdi5wYih4KTsKICAgICAgICAgICAgbVt4XSA9IDA7CiAgICAgICAgfQoKICAgICAgICB0ID09IDEgPyB2bC5wYih2KSA6IHZoLnBiKHYpOwogICAgfQoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgc3oodmwpOyArK2kpIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IHN6KHZsW2ldKTsgKytqKSB7CiAgICAgICAgICAgIG1bdmxbaV1bal1dKys7CiAgICAgICAgfQogICAgfQoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgc3oodmgpOyArK2kpIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IHN6KHZoW2pdKTsgKytqKSB7CiAgICAgICAgICAgIG1bdmhbaV1bal1dID0gLTE7CiAgICAgICAgfQogICAgfQoKICAgIGludCBhbnMgPSAwOwoKICAgIGZvciAoaXQgPSBtLmJlZ2luKCk7IGl0ICE9IG0uZW5kKCk7ICsraXQpIHsKICAgICAgICBpZiAoaXQtPnNlID09IHN6KHZsKSkgewogICAgICAgICAgICArK2FuczsKICAgICAgICB9CiAgICB9CgogICAgY291dCA8PCBhbnMgPDwgIlxuIjsKfQo=