jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
 
        long ans = (N-1)*N/2;
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
//  [cpp]
#include <stdio.h>

int main() {
	long long n, ans;
	scanf("%lld", &n);
	ans = n * (n - 1) / 2;
	printf("%lld\n", ans);
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	ll n;
	cin>>n;
	cout << n*(n-1)/2 << endl;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
  cout<<n*(n-1)/2;
}
//  [cpp]
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N;
  cin >> N;

  cout << (N*(N - 1))/2 << endl;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n ; cin >> n ;
    n--;
    cout << n*(n+1) / 2 << endl;    
    return 0;
}
//  [cpp]
// doot diddly donger cuckerino Hahahahahah


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

class DModSum {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    ll ans = n * (n - 1) / 2;
    
    cout << ans << endl;
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	DModSum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}
//  [c]
#include <stdio.h>

int main() {
	long long N;
	scanf("%lld", &N);
	printf("%lld\n", N * (N - 1) / 2);
	return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
  long long n;
  scanf("%lld",&n);
  printf("%lld\n",n*(n-1)/2);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) (((1+x)*x)/2)
#define sum(x) ((n*(n-1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];

  scanf("%lld",&n);
  printf("%lld",sum(n-1));

  return 0;
}
//  [c]
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    printf("%d\n",n*(n-1)/2);
}
//  [c]
main(long n){scanf("%ld",&n);printf("%ld",n*n--/2);}
//  [c]
main(n){scanf("%d",&n);printf("%d",(--n*n+n)/2);}
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = next()
    let ans = (BigInt(n) - 1n) / 2n * BigInt(n)
    console.log(ans.toString())
}
Main()
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let ans = 0n
    for(let i = 1; i<n;i++){
        ans += BigInt(i)
    }
    console.log(ans.toString())
}
Main()
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let ans = 0
    for(let i = 1; i<n;i++){
        ans += i
    }
    console.log(ans)
}
Main()
//  [go]
package main

import (
        "fmt"
)

func solution(n int) int {
        return n * (n - 1) / 2
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	ans := (N - 1) * N / 2
	out(ans)
}
//  [go]
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}
func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	fmt.Println(N * (N - 1) / 2)
}
//  [go]
package main

import "fmt"

func main() {
	// Code for D - ModSum
	var N int
	fmt.Scanf("%d", &N)
	if N == 2 {
		fmt.Println("1")
	} else {
		fmt.Println(N * (N / 2))
	}
}
//  [go]
package main

import (
        "fmt"
)

func solution(n int) int {
        out := 0
        for i := 1; i < n; i++ {
                out += i % (i + 1)
        }
        out += n % 1
        return out
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}
//  [go]
package main

import (
        "fmt"
)

func solution(n int) int {
        out := 0
        for i := 0; i <= n; i++ {
                if i == n {
                        out += i % 1
                } else {
                        out += i % (i + 1)
                }
        }
        return out
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}
//  [ruby]
N = gets.to_i
puts ((N-1)*N)/2
//  [ruby]
n = gets.to_i

puts (n - 1) * n / 2
//  [ruby]
n = gets.to_i

# (1..n).to_a.permutation(n).each_with_object({}) { |nums, hash|
#   hash[nums] = nums.each.with_index.inject(0) { |result, (num, i)| result + (i + 1) % num }
# }

puts (n - 1) * n / 2
//  [ruby]
n=gets.to_i
p (n-1)n/2
//  [ruby]
n = gets.chomp.to_i
arr = [*1..n]
han = n / 2
ans = 0
# if n % 2 == 0
#     mae = ((1 + han) * han) / 2
#     (han+1..n).each do |i|
#         aikata = n + 1 - i
#         iko = i % aikata
#         ans += iko
#     end
# elsif n % 2 != 0
#     mae = ((1 + han) * han) / 2
#     (han+2..n).each do |i|
#         aikata = n + 1 - i
#         iko = i % aikata
#         ans += iko
#     end
# end
# p mae
# puts ans + mae
saigo = n- 1
puts (1 + saigo) * saigo / 2
//  [ruby]
n = gets.chomp.to_i
puts (n * (n-1.0) / 2).to_i
//  [rust]
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let n: i64 = io.read();
    io.writeln((n * (n - 1)) / 2);
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}
//  [rust]
fn main() {
    let n: i64 = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim().parse().unwrap()
    };
    println!("{}", n * (n - 1) / 2);
}
//  [rust]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<usize>();

    let ans = (1+n) * n / 2 - n;

    println!("{}", ans);
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u32,
    }
    println!("{}", n*(n-1)/2);
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    if n == 1 {
        println!("1");
    } else {
        println!("{}", (n * (n - 1)) / 2);
    }
}
//  [swift]
let n = Int(readLine()!)!

var modSum = n * (n - 1) / 2

print(modSum)
//  [swift]
let n = Int(readLine()!)!

var i = 0
var o = 0
var tmp = 0
//for i in 1..<n {
//    o += n - i
  //print( tmp, o )
//}

print( n * (  n - 1 ) / 2  )
//  [swift]
var N: Int64 = Int64(readLine()!)!
print(N*(N-1)/2)
//  [swift]
import Foundation

var n = Int(readLine()!)!
var ans	= 0

for i in 1..<n-1 {
    ans	+= i
}
print(ans)
//  [swift]
var n = Int(readLine()!)!
var ans	= 0

for i in 1..<n-1 {
    ans	+= i
}
print(ans)
//  [swift]
var n = Int(readLine()!)!
var ans	= 0

for i in 1..< n-1 {
    ans	+= i
}
print(ans)
//  [typescript]
const lines=[];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
  const n = Number(lines[0].split);
  const p = new Arrary(n).map(m,i)=> {i});
  
  console.log(p)
  
});
//  [python]
N,M = map(int,input().split())
bit = [0]*M
for i in range(N):
    info = list(map(int,input().split()))[1:]
    for e in info:
        bit[e-1] += 1
cnt = 0
for b in bit:
    if b == N:
        cnt +=1
print(cnt)
//  [python]
n,m = map(int, input().split())
a = list()
m = [0 for i in range(m)]
for i in range(n):
    b = list(map(int, input().split()))
    for j in range(b[0]):
        m[b[j+1]-1] += 1
tabemono = 0
for i in m:
    if i == n:
        tabemono += 1
print(tabemono)
//  [python]
N_nin, M_ko = map(int, input().split())
like = []

for i in range(N_nin):
    tmp = list(map(int, input().split()))
    like.append(tmp[1:])

all_like = set(like[0])

for i in range(N_nin):
    all_like = (all_like & set(like[i])) 

print(len(all_like))
//  [python]
n, m = [int(i) for i in input().split()]
list_a = [[int(i) for i in input().split()] for j in range(0, n)]
list_ans = [1 for i in range(0, m)]
if n == 1:
    print(list_a[0][0])
    exit()
for i in range(0, n):
    for j in range(1, len(list_a[i])):
        if list_ans[list_a[i][j] - 1] == 1:
            list_ans[list_a[i][j] - 1] = 0
print(sum(list_ans))
//  [python]
n,m=map(int,input().split())
c=[]
cnt=0
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(1,len(a)):
        c.append(a[j])
    
for j in range(1,m+1):
    if c.count(j)==n:
        cnt += 1
print(c)
print(cnt)
//  [python]

N, M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
x = 0
for i in range(M+1):
    x += i
ct = 0
for j in range(N):
    if (sum(A[j])-A[j][0]) == x
    ct += 1
print(ct)
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int a[] = new int[m];
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      int k = Integer.parseInt(str[0]);
      for(int j=1; j<=k; j++) {
        int t = Integer.parseInt(str[j]);
        System.out.println(t);
        a[t-1]++;
      }
    }
    
    int count = 0;
    for(int i=0; i<m; i++) {
      if(a[i] == n)
        count++;
    }
    System.out.println(count);
  }
}
//  [java]
import java.util.*;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
        int a[] = new int[n-1];
        int b[][] = new int[n][30];
        int ans[] = new int[c]; 
        
        for(int i=0; i<c; i++){
            ans[i] = sc.nextInt();
        }
        
        for(int i=0; i<n-1; i++){
            a[i] = sc.nextInt();
            for(int j=0; j<a[i]; j++){
                b[i][j] = sc.nextInt();
            }
        }
        
        for(int i=0; i<c; i++){
            for(int j=0; j<n-1; j++){
                for(int k=0; k<a[j]; k++){
                    if(ans[i] != b[j][k]){
                        ans[i] = 0;
                    }
                }
            }
        }
        
        int flg = 0;
        
        for(int i=0; i<c; i++){
            if(ans[i]!=0){
                System.out.println(ans[c]);
                flg = 1;
            }
        }
        
        if(flg == 0){
            System.out.println(0);
        }
    }
}
//  [java]
import java.util.*;
import java.util.ArrayList;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    if(N == 1){
      int count1 = 0;
      int K1 = sc.nextInt();
      for(int i = 0; i < K1 ; i++){
        int love = sc.nextInt();
        if(love <= M){
          count1++;
        }
      }
      
      System.out.println(count1);
      
    }else{
    
    ArrayList<Integer> love = new ArrayList<Integer>();
    for(int i = 0; i < N ; i++){
      int K = sc.nextInt();
      int[] list = new int[K];
       for(int j = 0; j < K ; j++){
         list[j] = sc.nextInt();
         love.add(list[j]);
       }   
    }
    
    ArrayList<Integer> countAll = new ArrayList<Integer>();
    int count = 0;
    for(int i = 0; i < love.size() ; i++){
      int jd = love.get(i);
      for(int j = 0; j  < M ; j++){
        if(jd == j+1){
          count++;
        }
      }
      countAll.add(count);
      count = 0;
    }
    
    int lastCount = 0;
    for(int i = 0; i < M ; i++){
      if(countAll.get(i) == M){
        lastCount++;
      }
    }
    System.out.println(lastCount);   
    }
  }  
}
//  [cpp]
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>

#define INF 100000000

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[m] = {0};
    for (int i = 0; i < n; i++)
    {
        int k, tmp;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> tmp;
            a[tmp - 1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        if (a[i] == n)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch FoodsLovedByEveryone | diff FoodsLovedByEveryone.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address FoodsLovedByEveryone.cpp && ./a.out

/*
 
 2/28/2019
 
 15:33-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N,M;

void solve() {
  int res=0;
  REP(i,M) res+=(A[i]==N);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,N) {
    int K; cin>>K;
    REP(i,K) {
      int a; cin>>a;
      A[--a]++;
    }
  }
  solve();
  
  return 0;
}
//  [cpp]
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(int a)
{
    if (a != 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m;
    cin >> n >> m;

    bool like[31];
    rep(i, 0, m) like[i] = true;

    int a[31][31] = {}, k[31] = {};
    rep(i, 0, n)
    {
        cin >> k[i];
        rep(j, 0, k[i])
        {
            cin >> a[i][j];
        }
    }

    int ans = 0;
    rep(l, 1, m + 1)
    {
        //cout << "l=" << l << endl;
        rep(i, 0, n)
        {
            bool f = true;
            rep(j, 0, k[i])
            {
                //cout << a[i][j] << " ";
                if (a[i][j] == l)
                {
                    if (i == n - 1)
                    {
                        ans++;
                        //f = false;
                    }
                    break;
                }
                if (j == k[i] - 1)
                    f = false;
            }
            //cout << endl;
            if (!f)
                break;
        }
    }
    cout << ans << endl;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){

    int n, m; cin >> n >> m;
    int kind[50] = {};

    rep(i,n){
        int k; cin >> k;
        rep(i, k){
            int tmp; cin >> tmp;
            kind[tmp]++;
        }
    }

    int ans = 0;
    rep(i,m){
        if(kind[i] == n) ans++;
    }

    cout << ans << endl;

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

/* ----------------------end----------------------- */
signed main() {
    int N, M; cin >> N >> M;
    vvi A(N);
    vi K;
    rep(i, N) {
        int k; cin >> k;
        K.push_back(k);
        rep(i, k) {
            int a; cin >> a;
            A[i].push_back(a);
        }
    }
    vi like(M);
    rep(i, N) {
        for (int j = 0; j < K[i]; j++) {
            like[A[i][j]-1]++;
        }
    }
    int cnt = 0;
    rep(i, M) {
        if (like[i] == N)cnt++;
    }
    cout << cnt << endl;
}
//  [cpp]
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int N, M; cin >> N >> M;
    vvi A(N);
    vi K;
    rep(i, N) {
        int k; cin >> k;
        K.push_back(k);
        rep(i, k) {
            int a; cin >> a;
            A[i].push_back(a);
        }
    }
    vi like(M);
    rep(i, N) {
        for (int j = 0; j < K[i]; j++) {
            like[A[i][j]-1]++;
        }
    }
    int cnt = 0;
    rep(i, M) {
        if (like[i] == N)cnt++;
    }
    cout << cnt << endl;
}
//  [c]
#include<stdio.h>

int main(void)
{
  int n,m;
  scanf("%d%d",&n,&m);

  int i,j,k[n],a[n][m];
  int judge[m];
  for(i=0;i<m;i++)
    judge[i] = 0;
  for(i=0;i<n;i++){
    scanf("%d",&k[i]);
    for(j=0;j<k[i];j++){
      scanf("%d",&a[i][j]);
      judge[a[i][j]-1]++;
    }
  }

  int ans=0;
  for(i=0;i<m;i++)
    if(judge[i]==n){
      ans++;
    }

  printf("%d\n",ans);
  return 0;
}
//  [c]
#include <stdio.h>
int main(void)
{

    
	int n,m,A=0,k[30]={0},x,y;


	scanf("%d%d",&n,&m);
	    for(int i=0;i<n;i++){
        scanf("%d",&x);
       	    for(int j=0;j<x;j++){
              scanf("%d",&y);
                 k[y-1]++;
        }

 }
    for(int i=0;i<m;i++){
        if(k[i]==n) A++;}

    printf("%d",A);

}
//  [c]
#include<stdio.h>
int main(){
  int n, m;
  scanf("%d %d",&n,&m);
  
  int cnt[30] = {};
  int k, a;
  for(int i = 0; i < n; i++){
    scanf("%d",&k);
    for(int j = 0; j < k; j++){
      scanf("%d",&a);
      cnt[a-1]++;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < m; i++){
    if(cnt[i] == n){
      ans++;
    }
  }
  printf("%d",ans);
}
//  [c]
#include "stdio.h"

int main(){
    int N,M,K,i,j,F[31][31],t;
    scanf("%d%d",&N,&M);
    for(i=0;i<N;i++){
        scanf("%d",&K);
        for(j=0;j<K;j++){
            scanf("%d",&t);
            F[i][t]=1;
        }
    }
    t=0;
    for(i=1;i<=M;i++){
        int f=1;
        for(j=0;j<N;j++){
            if(F[j][i]!=1){
                f=0;
                break;
            }
        }
        if(f==1){
            t++;
        }
    }
    printf("%d",t);
    return 0;
}
//  [c]
#include "stdio.h"

int main(){
    int N,M,K,i,j,F[31][31],t;
    scanf("%d%d",&N,&M);
    for(i=0;i<N;i++){
        scanf("%d",&K);
        for(j=0;j<K;j++){
            scanf("%d",&t);
            F[i][t]=1;
        }
    }
    t=0;
    for(i=1;i<=M;i++){
        int f=1;
        for(j=0;j<N;j++){
            if(F[j][i]){
                f=0;
                break;
            }
        }
        if(f){
            t++;
        }
    }
    printf("%d",t);
    return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
        int n,m,k,i,j,s;
        scanf("%d%d",&n,&m);

        int a[n][m],c[m];

        for(i=0;i<m;i++)
                c[i]=0;

        for(i=0;i<n;i++){
                scanf("%d",&k);
                for(j=0;j<k;j++){
                        scanf("%d",a[i][j]);
                        c[a[i][j]]++;
                }
        }

        s=0;
        for(i=0;i<m;i++)
                if(c[i]==m) s++;

        printf("%d\n",s);
        return 0;
}
//  [javascript]
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
n = line[0] * 1
m = line[1] * 1 
arr = []
for (i=0; i<m; i++) {
    arr[i] = 0
}

for (i=0; i<n; i++) {
    line = lines[i].split(' ')
    k = line[0]
    for (j=1; j<=k; j++) {
        arr[line[j]-1] += 1 
    }
}

cnt = 0;
for (i=0; i<m; i++) {
    if (arr[i] == n) {
        cnt++
    }
}
console.log(cnt)
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n")
  tmp0 = input[0].split(" ")

  N = Number(tmp0[0])
  M = Number(tmp0[1])

  var ansArr=[];
  for(var i=0; i < M; i++){
    ansArr.push(0)
  }

  for(var i=1; i <= N; i++)
  {
    var tmp1 = input[i].split(" ")
    for(var j = 1; j < tmp1.length; j++){
      ansArr[tmp1[j]-1]++
    }
  }

  var ans=0
  for(var i=0; i < ansArr.length;i++)
  {
    if(ansArr[i] === N){
      ans++
    }
  }
  console.log(ans)

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("3 4\n2 1 3\n3 1 2 3\n2 3 2")
//  [javascript]
'use strict'

function main(input) {
  input = input.split('\n').map(v => v.split(' ').map(v => ~~v))
  const n = input[0][0]
  const m = input[0][1]
  const ans = input.slice(1, -1)
  const counts = Array.apply(null, { length: m + 1 }).fill(0)
  for (let i = 0; i < n; i++) {
    for (let j = 1; j <= ans[i][0]; j++) {
      counts[ans[i][j]] += 1
    }
  }

  const f = counts.filter(v => {
    return v >= n
  })

  console.log(f.length)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function main(input) {
  const args = input.split('\n');
  const a = args[0].split(' ').map(n => parseInt(n, 10));
  const N = a[0];
  const M = a[1];
  
  let list = {};
  let ans = 0;
  
  //リスト初期化
  for (let i = 1; i <= M; i++) {
    list[i] = 0;
  }
  
  //各人の好きな食べ物ループ
  for (let i = 1; i <= N; i++) {
    ary = args[i].split(' ').map(n => parseInt(n, 10));
    for (let j = 1; j <= ary[0]; j++) {
      key = ary[i];
      list[key]++;
    }
  }
  
  //みんなが好きならプラスする
  for (key in list) {
    if (list[key] === N) { ans++; }
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const [N, M] = input[0].split(' ')
  const K = input.slice(1)
  let ans = Array.from(new Array(Number(M))).map((v, i) => i + 1)
  for (let i = 0; i < K.length; i++) {
    const tmp = K[i].split(' ').slice(1).map(n => Number(n))
    for (let j = 0; j < ans.length; j++) {
      if (!tmp.includes(ans[j])) {
        ans[j] = null
      }
    }
  }
  console.log(ans.filter(v => v != null).length)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
n,m=map(int,input().split())
count=0
ans=0
d=[0]*m
for i in range(n):
  a=list(map(int,input().split()))
  a.pop(0)
  for j in a:
    d[j-1]+=1
print(d.count(n))
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	n, m := readInt(), readInt()
	cnt := map[int]int{}
	for i := 0; i < m; i++ {
		cnt[i+1] = 0
	}

	for i := 0; i < n; i++ {
		k := readInt()
		for j := 0; j < k; j++ {
			cnt[readInt()]++
		}
	}

	ans := 0
	for _, v := range cnt {
		if v == n {
			ans++
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}
	m, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}
	
	if n == 1 {
		k, err := strconv.Atoi(input())
		if err != nil {
			log.Fatalln(err)
		}
		fmt.Println(k)
		return
	}

	list := make(map[int]int)

	for i := 1; i <= m; i++ {
		list[i] = 0
	}

	for i := 0; i < n; i++ {
		k, err := strconv.Atoi(input())
		if err != nil {
			log.Fatalln(err)
		}
		for j := 0; j < k; j++ {
			a, err := strconv.Atoi(input())
			if err != nil {
				log.Fatalln(err)
			}
			list[a] += 1
		}
	}

	count := 0
	for _, v := range list {
		if v == n {
			count++
		}
	}

	fmt.Println(count)
}
//  [go]
package main

import "fmt"

func main() {
	var n, m int
	var previous []int

	fmt.Scanf("%d %d", &n, &m)
	for tmp := 0; tmp < m; tmp++ {
		previous = append(previous, tmp)
	}

	for i := 0; i < n; i++ {
		var now []int
		var k int
		fmt.Scanf("%d", &k)
		for j := 0; j < k; j++ {
			var a int
			fmt.Scanf("%d", &a)
			now = append(now, a)
		}
		previous = Uniform(previous, now)
	}
	fmt.Println(len(previous))
}

func In(a int, list []int) bool {
	for _, b := range list {
		if b == a {
			return true
		}
	}
	return false
}
func Uniform(previous, now []int) []int {
	var res []int
	for _, i := range now {
		if In(i, previous) {
			res = append(res, i)
		}
	}
	return res
}
//  [go]
package main

import (
  "fmt"
)

func main() {
  var n, m int 
  fmt.Scan(&n, &m)
  res := 1 << uint(m) - 1
  for i := 0; i < n; i++ {
    var k int 
    fmt.Scan(&k)
    like := 0
    for j := 0; j < k; j++ {
      var a uint 
      fmt.Scan(&a); a--
      like |= 1 << a
    }
    res &= like 
  }
  cnt := 0
  for i := uint(0); i < m; i++ {
    if res >> i & 1 == 1 {cnt++}
  }
  fmt.Println(cnt)

}
//  [go]
package main

import (
  "fmt"
)

func main() {
  var n, m int 
  fmt.Scan(&n, &m)
  res := 1 << uint(m) - 1
  for i := 0; i < n; i++ {
    var k int 
    fmt.Scan(&k)
    like := 0
    for j := 0; j < k; j++ {
      var a uint 
      fmt.Scan(&a); a--
      like |= 1 << a
    }
    res &= like 
  }
  cnt := 0
  for i := 0; i < m; i++ {
    if res >> i & 1 == 1 {cnt++}
  }
  fmt.Println(cnt)

}
//  [ruby]
nm = gets.chomp.split
n = nm[0].to_i
m = nm[1].to_i

foods = Array.new(m+1, 0)

n.times do
    input = gets.chomp.split
    k = input[0].to_i
    k.times do |i|
        a = input[i+1].to_i
        foods[a] += 1
    end
end

puts foods.count(n)
//  [ruby]
# frozen_string_literal: true

n, _m = gets.split.map(&:to_i)
h = Hash.new(0)
n.times do
  gets.split.map(&:to_i)[1..-1].each { |i| h[i] += 1 }
end

puts h.values.count { |i| i == n }
//  [ruby]
n,m = gets.split.map(&:to_i)

ans = [0]*(m+1)
n.times do |i|
  a = gets.split.map(&:to_i)
  k = a.shift
  a.each do |j|
    ans[j] += 1
  end
end

puts ans.count(n)
//  [ruby]
N,M = gets.chomp.split.map(&:to_i)
ary = (1..m).to_a

N.times do |i|
  buf = gets.chomp.split.map(&:to_i)
  ary = ary & buf[1..-1]
end

puts ary.length
//  [ruby]
n,m = gets.split.map(&:to_i)

a = gets.split.map(&:to_i)
t = a.slice(0,a[0])

(n-1).times do |i|
    a = gets.split.map(&:to_i)
    a = a.slice(0,a[0])
    t = t & a
end

# p t
p t.size
//  [ruby]
n, m = gets.split.map(&:to_i)
ans = []
n.times do
  ans.concat(gets.split.map(&:to_i)[1..-1])
end

(1..m).each do |i|
  if ans.count(i) == n
    count+=1
  end
end
puts count
//  [rust]
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, m) = input_tuple();
    let mut flag = vec![0; m as usize];
    for _ in 0..n {
        let v = input_vec();
        let k = v[0];
        for i in 1..(k+1) {
            flag[v[i as usize] as usize - 1] += 1;
        }
    }
    // println!("{:?}", flag);
    let mut count = 0;
    for f in flag {
        if f == n {
            count += 1;
        }
    }
    println!("{}", count);
}
//  [rust]
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut a: Vec<i32> = Vec::with_capacity(m+1);
    let mut count: i32 = 0;
    unsafe{
	a.set_len(m+1);
    }
    for i in 0..m+1{
	a[i as usize] = 0;
    }
    for _i in 0..n{
	let k: usize = read();
	for _j in 0..k{
	    let b: usize = read();
	    a[b]+=1;
	}
    }
    for i in 0..m+1{
	if a[i as usize] == n as i32{
	    count+=1;
	}
    }
    println!("{}",count);
}
//  [rust]
use std::io::Read;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut h = vec![0; m];

    for _ in 0..n {
        let k: usize = iter.next().unwrap().parse().unwrap();
        for _ in 0..k {
            let a: usize = iter.next().unwrap().parse().unwrap();
            h[a - 1] += 1;
        }
    }

    println!("{}", h.iter().filter(|&x| *x == n).count());
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: isize, l: isize};
    let mut v: Vec<i32> = Vec::new();

    for i in l..l + n {
        v.push(i as i32);
    }

    let mut min: i32 = 1_000_000;
    let mut x: i32 = 0;

    for v_i in v.iter() {
        if min > v_i.abs() {
            min = v_i.abs();
            x = *v_i;
        }
    }

    println!("{}", v.iter().sum::<i32>() - x);
}
//  [rust]
use proconio::input;
use proconio::marker::Usize1;

fn main() {
   input! {
     n: usize,
     m: usize,
     ks: [[Usize1]; n]
   }
   let mut cnt = vec![0; m];
   let mut ans = 0;
   for k in ks.iter() {
     for &c in k.iter() {
       cnt[c] += 1;
     }
   }
   for v in cnt {
     if v == n {
       ans += 1;
     }
   }
   println!("{:?}", ans);
}
//  [swift]
let NM: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
var num: [Int] = Array(repeating: 0, count: NM[1])
for _ in 1...NM[0] {
    
    for A in readLine()!.split(separator: " ").map({ Int($0)! }).dropFirst() {
        num[A-1] += 1
    }
}
var res: Int = 0
for a in num {
    if a == NM[0] { res += 1}
}
print(res)
//  [swift]
import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let N = Int(input[0])!
let M = Int(input[1])!

var cnt = Array(count: M, repeatedValue: 0)

for _ in 0 ..< N {
    let input = readLine()!.componentsSeparatedByString(" ")
    let K = Int(input[0])!
    for i in 0 ..< K {
        let A = Int(input[i + 1])! - 1
        cnt[A] += 1
    }
}

var ans = 0
for i in 0 ..< M {
    if cnt[i] == N {
        ans += 1
    }
}

print(ans)
//  [swift]
import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let N = Int(input[0])!
let M = Int(input[1])!

var cnt = Array(count: M, repeatedValue: 0)

for _ in 0 ..< N {
    let input = readLine()!.componentsSeparatedByString(" ")
    let K = Int(input[0])!
    for i in 0 ..< K {
        let A = Int(input[i+1])! - 1
        cnt[A] += 1
    }
}

var ans = 0
for i in 0 ..< M {
    if cnt[i] == N {
        ans += 1
    }
}

print(ans)