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>
#define N_MAX 101

using namespace std;

int main(){

  while( 1 ){
    int n, m;
    int table[ N_MAX ][ N_MAX ];
    int possible[ N_MAX ];
    cin >> n;
    if( !n ){ return 0; }
    for( int i = 1; i <= n; i++ ){
      possible[ i ] = 1;
      for( int j = 1; j <= n; j++ ){
        table[ i ][ j ] = 0;
      }
    }

    for( int i = 1; i <= n; i++ ){
      cin >> m;
      for( int j = 0; j < m; j++ ){
        int temp;
        cin >> temp;
        table[ i ][ temp ] = 1;
      }
    }
    int k;
    cin >> k;
    for( int i = 0; i < k; i++ ){
      int temp;
      cin >> temp;
      for( int j = 1; j <= n; j++ ){
        if( !table[ j ][ temp ] ){
          possible[ j ] = 0;
        }
      }
    }
    int crimer = -1;
    int counter = 0;
    for( int i = 1; i <= n; i++ ){
      if( possible[ i ] ){
        crimer = i;
        counter++;
      }
      if( counter >= 2 ){
        crimer = -1;
        break;
      }
    }
    cout << crimer << endl;
  } 
}

C++: #include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iterator>
#include <sstream>

using namespace std;

int N;
bool p[100][100];

int main()
{
	while(cin>>N,N){
		for (int i = 0; i < N; i++){
			int m; cin>>m;
			for (int j = 0; j < m; j++){
				int x; cin>>x;
				x--;
				p[i][x] = true;
			}
			//p[i][i] = true;
		}
		int k; cin>>k;
		vector<int> l(k);
		for (int i = 0; i < k; i++){ cin>>l[i]; l[i]--;}

		int ans = -1;
		for (int i = 0; i < N; i++){
			int j;
			for (j= 0; j< k; j++){
				if(!p[i][l[j]]) break;
			}
			if(j == k){
				if(ans == -1){
					ans = i + 1;
				} else {
					ans = -1; break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	while (scanf("%d", &n), n){
		bitset<100> s[100];
		for (int i = 0; i < n; i++){
			int m;
			scanf("%d", &m);
			for (int j = 0; j < m; j++){
				int p;
				scanf("%d", &p);
				s[i].set(--p);
			}
		}
		
		bitset<100> t;
		int k;
		scanf("%d", &k);
		for (int i = 0; i < k; i++){
			int l;
			scanf("%d", &l);
			t.set(--l);
		}
		
		int res = -1;
		for (int i = 0; i < n; i++){
			bitset<100> tmp = s[i] &= t;
			if (tmp == t){
				if (res == -1) res = i + 1;
				else {
					res = -1;
					break;
				}
			}
		}
		
		printf("%d\n", res);
	}
	
	return 0;
}

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <array>

using namespace std;

int main ()
{
	int N;
	while( cin >> N , N )
	{
		int a , b;
		vector<vector<int>>data;
		data.resize ( N );
		for( size_t i = 0; i < N; i++ )
		{
			data[i].resize ( N );
			cin >> a;
			for( size_t j = 0; j < a; j++ )
			{
				cin >> b;
				b--;
				data[i][b] = 1;
			}
			data[i][i] = 1;
		}
		cin >> a;
		vector<int>data2;
		data2.resize ( N );
		for( size_t i = 0; i < a; i++ )
		{
			cin >> b;
			b--;
			data2[b] = 1;
		}
		set<int>data3;
		for( size_t i = 0; i < N; i++ )
		{
			bool f = 1;
			for( size_t j = 0; j < N; j++ )
			{
				if( data2[j] && !data[i][j] )
				{
					f = 0;
					break;
				}
			}
			if( f )
			{
				data3.insert ( i );
			}
		}
		if( data3.size () == 1 )
		{
			cout << *data3.begin () + 1 << endl;
		} else
		{
			cout << -1 << endl;
		}
	}
	return 0;
}