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<set>
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        set<int> s[n];
        for(int i = 0; i < n; i++){
            int m, p;
            cin >> m;
            while(m-- > 0){
                cin >> p;
                s[i].insert(p);
            }
        }

        int k;
        cin >> k;
        int l[k];
        for(int i = 0; i < k; i++)  cin >> l[i];

        int ans = -1;
        for(int i = 0; i < n; i++){
            int cnt = 0;
            for(int j = 0; j < k; j++)  cnt += s[i].count(l[j]);
            if(cnt == k){
                if(ans != -1){
                    ans = -1;
                    break;
                }
                ans = i+1;
            }
        }

        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <set>
#include <vector>

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<set<int> > member(n);
    for(int i=0,m;i<n;++i){
      cin>>m;
      for(int j=0,p;j<m;++j){
        cin>>p;
        member[i].insert(p);
      }
    }
    int k;
    cin>>k;
    vector<int> skimmed(k);
    for(int i=0;i<k;++i)cin>>skimmed[i];
    set<int> ans;
    for(int i=0;i<n;++i){
      bool f=true;
      for(int j=0;j<k;++j){
        if(!member[i].count(skimmed[j])){f=false;break;}
      }
      if(f)ans.insert(i+1);
    }
    if(ans.size()==1)cout<<*(ans.begin())<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <set>
using namespace std;
#define rep(i, b) for (int i = 0; i < int(b); i++)

int main(){
    int n;
    while (cin >> n, n){
        set<int> know[100];
        rep(i, n){
            int m; cin >> m;
            rep(j, m){
                int t; cin >> t;
                t--;
                know[i].insert(t);
            }
        }

        int k; cin >> k;
        bool bad[100] = {};
        rep(i, k){
            int t; cin >> t;
            t--;
            rep(j, n){
                if (know[j].count(t) == 0) bad[j] = true;
            }
        }
        int ans;
        int c = 0;
        rep(i, n){
            if (!bad[i]){
                ans = i + 1;
                c++;
            }
        }
        if (c == 1) cout << ans;
        else cout << -1;
        cout << endl;
    }
}

C++: #define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;

int main(){
  int agent_num;
  while(~scanf("%d",&agent_num)){
    if(agent_num == 0) break;
    vector<int> agent_info[101];
    for(int i=1;i<=agent_num;i++){
      int node_num;
      scanf("%d",&node_num);
      
      int to_node;
      for(int j=0;j<node_num;j++){
	scanf("%d",&to_node);
	agent_info[i].push_back(to_node);
      }
    }
    int leaked_num;
    int leak[101];
    scanf("%d",&leaked_num);
    for(int j=0;j<leaked_num;j++){
      scanf("%d",leak+j);
    }

    int criminal_num = 0;
    int criminal_idx = 0;
    for(int i=1;i<=agent_num;i++){
      int count = 0;
      for(int j=0;j<agent_info[i].size();j++){
	for(int k=0;k<leaked_num;k++){
	  if(leak[k] == agent_info[i][j]){
	    count++;
	    break;
	  }
	}
	
      }
      if(count >= leaked_num){
	criminal_idx = i;
	criminal_num++;
      }
    }

    printf("%d\n",criminal_num != 1 ? -1: criminal_idx);
  }
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main(){
	int data[100][100], M[100], N, K, l[100], flag[100][100], root[100];
	
	while(1){
		cin >> N;
		if(N == 0)
			break;
		
		for(int i = 0; i < 100; i++){
			M[i] = l[i] = 0;
			root[i] = 1;
			for(int j = 0; j < 100; j++)
				data[i][j] = flag[i][j] = 0;
		}
		
		for(int i = 0; i < N; i++){
			cin >> M[i];
			for(int j = 0; j < M[i]; j++){
				cin >> data[i][j];
				flag[i][data[i][j] - 1] = 1;
			}
		}
		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++){
				if(flag[j][l[i] - 1] == 0)
					root[j] = 0;
			}
		}
		
		int count = 0;
		for(int i = 0; i < N; i++){
			if(root[i] == 1)
				count++;
		}
		
		if(count == 1){
			for(int i = 0; i < N; i++){
				if(root[i] == 1){
					cout << i + 1 << endl;
					break;
				}
			}
		}
		else
			cout << -1 << endl;
	}
	
	return 0;
}

C++: 

#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
#include <map>
#include <stack>
using namespace std;
 
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,-1,1,-1,1};
 
 
int main() {
int m;
while(cin>>m && m){
int a[110][110]={0};
int b[110]={0};
int n,l;
for(int i=1;i<m+1;i++){
cin>>n;
for(int j=0;j<n;j++){
cin>>l;
a[i][l]=1;
}
}
cin>>n;
for(int j=0;j<n;j++){
cin>>l;
b[l]=1;
}
int ans=0,ans1=0;
for(int i=1;i<m+1;i++){
int y=0;
for(int j=1;j<m+1;j++){
y=y+a[i][j]*b[j];
}
//cout<<y<<endl;
if(y==n) {
ans++;
ans1=i;
}
}
if(ans==1) cout<<ans1<<endl;
else cout<<"-1"<<endl;



}

	return 0;
 
   }