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>
using namespace std;
int x[200][200], y[200], z[200], n, i, a, j, k, b, s, c;
int main() {
	while (true) {
		cin >> n; b = 0;
		if (!n) { break; }
		for (i = 1; i <= n;i++){
			cin >> z[i];
			for (j = 0; j < z[i];j++){
				cin >> x[i][j];
			}
		}
		cin >> a;
		for (i = 0; i < a; i++) { cin >> y[i]; }
		for (i = 1; i <= n; i++) {
			s = 0;
			for (j = 0; j < a; j++) {
				for (k = 0; k < z[i]; k++) {
					if (x[i][k] == y[j]) {
						s++;
					}
				}
			}
			if (s == a) { c = i; b++; }
		}
		if (b - 1) { c = -1; }
		cout << c << endl;
	}
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;
	
	vector<vector<int> > vvi(n);
	for(int i=0;i<n;i++){
		int n2;
		cin>> n2;
		for(int j=0;j<n2;j++){
			int in;
			cin>> in;
			vvi[i].push_back(in);
		}
	}
	vector<int> out;
	int m;
	cin>> m;
	for(int i=0;i<m;i++){
		int in;
		cin>> in;
		out.push_back(in);
	}
	
	int ans = 0;
	for(int i=0;i<n;i++){
		bool flag = true;
		for(int j=0;j<out.size();j++){
			if(find(vvi[i].begin(), vvi[i].end(), out[j]) == vvi[i].end()) flag = false;
		}
		if(flag){
			if(ans){
				cout<< -1<< endl;
				return true;
			}else{
				ans = i+1;
			}
		}
	}
	if(ans){
		cout<< ans<< endl;
	}else{
		cout<< -1<< endl;
	}
	return true;
	
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int a[1000][1000];
int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    int b,d;
    lp(i,n){
      cin>>b;
      lp(j,b){
	cin>>d;
	a[i][d]=1;
      }
    }
    int count=0,ans,check;
    int c;
    cin>>c;
    int x[1000];
    lpin(x,i,c);
    lp(i,n){
      check=0;
      lp(j,c){
	if(a[i][x[j]]==1) 1;
	else check=1;
      }
      if(check==0){
	ans=i;
	count++;
      }
    }
    if(c==0) cout<<"-1"<<endl;
    else if(count==1) cout<<ans+1<<endl;
    else cout<<"-1"<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int n;
bool t[200][200];

void init(){
  for(int i=0;i<200;i++){
    for(int j=0;j<200;j++){
      t[i][j]=false;
    }
  }
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    init();
    int a,b;
    for(int i=0;i<n;i++){
      cin>>a;
      while(a--){
	cin>>b;
	t[i][b]=true;
      }
    }
    int u[200]={};
    cin>>a;
    while(a--){
      cin>>b;
      u[b]=true;
    }
    vector<int> ans;
    for(int i=0;i<n;i++){
      bool flg=true;
      for(int j=0;j<200;j++){
	if(u[j]&&!t[i][j])flg=false;
      }
      if(flg)ans.push_back(i+1);
    }
    if(ans.size()==1)cout<<ans[0]<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 102;
vector<int> info[MAX_N];

int main()
{
	ios_base::sync_with_stdio(0);
	int N;
	while (cin >> N, N ){
		rep (i, N ) info[i].clear();
		rep (i, N ){
			int M; cin >> M;
			rep (j, M ){
				int p; cin >> p;
				p--;
				info[i].push_back (p );
			} // end rep
			sort (ALL (info[i] ) );
		} // end rep
		int K; cin >> K;
		vector<int> leak; leak.clear();
		rep (i, K ){
			int l; cin >> l;
			l--;
			leak.push_back (l );
		} // end rep
		sort (ALL (leak ) );
		int cnt = 0;
		int res = -1;
		rep (i, N ){
			int cur = 0;
			rep (j, leak.size() ){
				rep (k, info[i].size() ){
					if (info[i][k] == leak[j] ){
						cur++;
					} // end if
				} // end rep
			} // end rep
			if (cur == leak.size() ){
				res = i+1; cnt++;
			} // end if
		}// end rep
		if (cnt == 1 ){
			cout << res << endl;
		}else{
			cout << -1 << endl;
		} // end if
	} // end while
		
	return 0;
}