Go: package main

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

func main() {
	io := NewIo()
	defer io.Flush()

	for {
		N := io.NextInt()
		if N == 0 {
			break
		}
		set := make([]map[int]struct{}, N)
		for i := 0; i < N; i++ {
			set[i] = make(map[int]struct{})
			M := io.NextInt()
			for j := 0; j < M; j++ {
				p := io.NextInt()
				set[i][p] = struct{}{}
			}
		}
		K := io.NextInt()
		l := make([]int, K)
		for i := 0; i < K; i++ {
			l[i] = io.NextInt()
		}

		ans := 0
	FOR_OUTER:
		for i := 0; i < N; i++ {
			for j := 0; j < K; j++ {
				if _, f := set[i][l[j]]; f == false {
					continue FOR_OUTER
				}
			}
			switch ans {
			case 0:
				ans = i + 1
			default:
				ans = -1
			}
		}
		if ans > 0 {
			io.Println(ans)
		} else {
			io.Println(-1)
		}
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: 
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

// bad knowhow
#define REP(i,n) for(long long i=0;i<(long long)n;++i)

#include <set>
set<int> g_p[100];
set<int> g_leak;

int main() {

	while (true) {
		int n;
		cin >> n;
		REP(i, 100) g_p[i].clear();
		g_leak.clear();
		if (n==0) break;
		REP(i, n) {
			int m;
			cin >> m;
			REP(j, m) {
				int p;
				cin >> p; --p;
				g_p[i].insert(p);
			}
		}
		int k;
		cin >> k;

		REP(i, k) {
			int l;
			cin >> l;
			--l;
			g_leak.insert(l);
		}

		int suspect = -2;
		for (int i = 0; i < n; ++i) {
			auto it = g_leak.begin();
			for (; it!=g_leak.end();++it) {
				if(g_p[i].count(*it)==0) break;
			}
			if (it==g_leak.end()){
				if (suspect == -2) suspect = i;
				else{
					suspect = -2;
					break;
				}
			};
		}

		cout << suspect + 1 << endl;
	}
}

C++: #include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N;
    while (1)
    {
        cin >> N;
        if (N == 0)
            break;
        bool f[110][110] = {};
        rep(i, N)
        {
            int M;
            cin >> M;
            rep(j, M)
            {
                int p;
                cin >> p;
                p--;
                f[i][p] = true;
            }
        }
        int K;
        cin >> K;
        vector<int> l(K);
        rep(i, K) cin >> l[i], l[i]--;
        int ans = -1;
        rep(i, N)
        {
            bool che = true;
            rep(j, K) if (!f[i][l[j]]) che = false;
            if (che)
            {
                if (ans == -1)
                    ans = i + 1;
                else
                {
                    ans = -1;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

C++: #include<iostream>
//#include<fstream>
#include<vector>
#include<stack>

using namespace std;

int main() {
	//ifstream fin("in.txt");

	int n = 0;

	while (cin >> n) {

		if (n == 0)break;

		//???????????\???
		vector<vector<int>> member;

		for (int i = 0; i < n; i++) {

			int num = 0;
			cin >> num;

			vector<int> piece;

			for (int i = 0; i < num; i++) {
				int tmp = 0;
				cin >> tmp;
				piece.push_back(tmp);
			}
			member.push_back(piece);
		}

		int k = 0; 
		cin >> k;

		vector<int> ans;

		for (int i = 0; i < k; i++) {
			int tmp;
			cin >> tmp;
			ans.push_back(tmp);
		}

		//???????????\????????????

		int ansNum = 0;
		bool same = false;

		for (int i = 0; i < member.size(); i++) {
			if (ans.size() <= member[i].size()) {
				for (int j = 0; j < ans.size(); j++) {
					same = false;
					for (int k = 0; k < member[i].size(); k++)
						if (ans[j] == member[i][k])same = true;
					if (same)continue;
					else break;
				}
				if (same) {
					if(ansNum == 0)ansNum = i + 1;
					else ansNum = -1;
				}
			}
		}
		if (ansNum == 0)ansNum = -1;

		cout << ansNum << endl;

	}


	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	// n := 人数
	int n;
	while( cin >> n , n ){
		// s[i][j] := j は i さんの個人情報を知っているかどうか.
		int s[101][101] = {0};
		
		for(int i=0 ; i < n ; i++ ){
			int m;
			cin >> m;
			for(int j=0 ; j < m ; j++ ){
				int p;
				cin >> p;
				p--;
				// i さんは p さんの個人情報を知っている.
				s[p][i] = 1;
			}
		}
		// k := 個人情報が漏洩した人数.
		int k;
		cin >> k;
		// L := 個人情報が漏洩した人の番号を保持する配列.
		vector<int> L;
		for(int i=0 ; i < k ; i++ ){
			int l;
			cin >> l;
			l--;
			L.push_back( l );
		}
		// ans := 個人情報を漏らした可能性のある人の番号を保持する配列.
		vector<int> ans;
		
		for(int x=0 ; x < n ; x++ ){
			bool flag = true;
			// foo := x さんが知っている人の番号を保持する配列
			vector<int> foo;
			
			for(int y=0 ; y < n ; y++ ){
				if( s[y][x] ){
					foo.push_back( y );
				}
			}
			for(int i=0 ; i < L.size() ; i++ ){
				// x さんは L[i] さんの情報を漏らした可能性がなければ flag を false にしておく.
				if( count(foo.begin() , foo.end() , L[i] ) == 0 ){
					flag = false;
				}
			}
			// x さん が個人情報を漏らした可能性のある人なら ans に追加.
			
			if( flag ){
				ans.push_back( x );
			}
		}
		
		// 個人情報を漏らした可能性のある人物が一人だけならその番号を出力, そうでなければ -1 を出力.
		if( ans.size() == 1 ){
			cout << (ans[0]+1) << endl;
		}else{
			cout << -1 << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
	int p[110][110], N, M[110], K, l[110];
	while(1){
		int a = 0, b[110] = {}, c = 0;

		cin>>N;
		if(N == 0) break;

		for(int i = 0; i < N; i++){
			cin>>M[i];
			for(int j = 0; j < M[i]; j++){
				cin>>p[i][j];
			}
		} 
		cin>>K;
		for(int i = 0; i < K; i++){
			cin>>l[i];
		}
	
		for(int i = 0; i < K; i++){
			for(int j= 0; j < N; j++){
				int x = 0;
				if(b[j] == 1){
				} else {
					for(int k = 0; k < M[j];k++){
						if(l[i] == p[j][k]){
							x = 1;
						}
					}
					
					if(x == 0) b[j] = 1;
				}
			}
		}
		
		for(int i = 0; i < N; i++){
			if(b[i] == 0) {
				a++;
				c = i;
			}
			
		}
		if(a == 1) cout<<c + 1<<endl;
		else cout<<"-1"<<endl;
	}
	return 0;
}