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 <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	int n;
	while(cin >> n, n) {
		int f[101][101] = {};
		FOR(i, 1, n+1) {
			int m; cin >> m;
			FOR(j, 1, m+1)
				cin >> f[i][j];
		}
		int k; cin >> k;
		int l[k], cnt, ans = 0;
		REP(i, k)
			cin >> l[i];
		FOR(i, 1, n+1) {
			cnt = 0;
			FOR(j, 1, n+1) {
				if(f[i][j] == l[cnt])
					cnt++; 
				if(cnt == k) {
					if(!ans) ans = i;
					else ans = -1;
					break;
				}
			}
		}
		if(ans < 1) ans = -1;
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int h[101][101];
    for(int i=0;i<=n;i++){
      cin>>h[i][0];
      for(int j=1;j<=h[i][0];j++)cin>>h[i][j];
    }
    int m[101]={};
    for(int i=1;i<=h[n][0];i++)
      for(int j=0;j<n;j++)
	for(int k=1;k<=h[j][0];k++)
	  if(h[j][k]==h[n][i])m[j]++;
    int cnt=0,ans;
    for(int i=0;i<n;i++)
      if(m[i]==h[n][0]){
	cnt++;
	ans=i+1;
      }
    
    if(cnt==1)cout<<ans<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) {
            break;
        }

        VII table(n);
        int number;
        int temp;
        VI ans;

        for (int i = 0; i < n; i++) {
            cin >> number;
            if (number == 0) {
                continue;
            }
            for (int j = 0; j < number; j++) {
                cin >> temp;
                table[i].push_back(temp);
            }
        }
        for (int j = 0; j < n; j++) {
            sort(table[j].begin(), table[j].end());
        }
        cin >> number;
        for (int j = 0; j < number; j++) {
            cin >> temp;
            ans.push_back(temp);
        }
        sort(ans.begin(), ans.end());


        int count = 0;
        int output;
        for (int i = 0; i < n; i++) {
            /*
            for (int m = 0; m < table[i].size(); m++) {
                cout << table[i][m] <<endl;
            }
            cout << endl;
            if (table[i].size() < ans.size()) {
                continue; 
            }
            */

            int j = 0;
            for (int k = 0; k < table[i].size(); k++) {
            //cout << "J = " << j << endl;
            //cout << table[i][k] << " " << ans[j] << endl;
                if (table[i][k] == ans[j]) {
                    j++;
                }
                if (j == ans.size()) {
                    count++;
                    output = i + 1;
                }
            }
        }
        if (count != 1) {
        cout << -1 << endl;
        } else {
            cout << output << endl;
        }
    }

    return 0;
}

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

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int N, M, tmp;
		cin >> N;
		if( N == 0 ) break;

		vector< vector< int > >data;
		vector< int > plist;
		for(int i = 0; i <= N; i++) plist.push_back(0);

		//データ入力
		for(int i = 0; i < N; i++) {
			cin >> M;
			vector<int> newdata;
			for(int j = 0; j < M; j++) {
				cin >> tmp;
				plist.at( tmp ) ++;
				newdata.push_back( tmp );
			}
			data.push_back( newdata );
		}

		//流出情報取得
		int K;
		int flg = false;
		vector<int> leak;
		cin >> K;
		for(int i = 0; i < K; i++) {
			int tmp;
			cin >> tmp;
			if( plist.at(tmp) == 1 )
				leak.push_back( tmp );
			else if(plist.at(tmp) == 0)
				flg = true;
		}

		//leakは、対応するインデックスの個人情報を1人しか知らない流出番号
		vector<int> suspect;
		for(int i = 0; i <= N; i++)
			suspect.push_back( 0 );

		for(int i = 0; i < data.size(); i++) {
			for(int j = 0; j < data.at(i).size(); j++) {
				for(int k = 0; k < leak.size(); k++) {
					if( data.at( i ).at( j ) == leak.at( k ) ) {
						suspect.at( i + 1 ) ++;
						break;
					}
				}
			}
		}

		vector<int> ans;
		for(int i = 0; i < suspect.size(); i++)
			if( suspect.at(i) > 0 ) ans.push_back( i );

		if( ans.size() == 1 && flg == false ) {
			cout << ans.at( 0 ) << endl;
		} else {
			cout << -1 << endl;
		}

	}

	//while(1){}

	return 0;
}