#include <iostream>
using namespace std;
int main()
{
int n, group, num, tmp;
while(cin >> n)
{
int CRC[100001] = {0};
while(n--)
{
cin >> group >> num;
for(int i = 1; i <= num; ++i)
{
cin >> tmp;
CRC[tmp] = group;
}
}
cin >> tmp;
cout << CRC[tmp] << endl;
}
return 0;
}