#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
using namespace std;
const int M=1e9+5;
const int maxn=2e5+5;
int A[205],cnt[205],vis[205];
struct Node
{
int x,h,l;
}node[maxn],ans[205];
bool cmp1(const Node s1,const Node s2)
{
return s1.x<s2.x;
}
bool cmp2(const Node s1,const Node s2)
{
return s1.h<s2.h;
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(cnt,0,sizeof(cnt));
memset(vis,0,sizeof(vis));
for(int i=0;i<n;i++)
scanf("%d",&A[i]);
int tot=0;
for(int i=0;i<n;i++)
for(int j=1;j<=A[i];j++)
{
scanf("%d",&node[tot].x);
node[tot].h=i