#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#define member_max 1001
#define team_max 101
struct team
{
bool flag;
int member[member_max];
int pos;
bool fla[member_max];
};
struct person
{
int serve;
bool fla;
int teamin[team_max];
int pos;
};
int n,m;
team data[team_max];
person dat[member_max];
using namespace std;
int main()
{
int i,j,a,b;
int sor[member_max][2];
freopen("cookie.in","r",stdin);
freopen("cookie.out","w",stdout);
scanf("%d%d",&n,&m);
memset(data,0,sizeof(data));
memset(dat,0,sizeof(dat));
memset(sor,0,sizeof(sor));
for (i=1;i<=m;i++)
{
scanf("%d",&a);
for (j=1;j<=a;j++)
{
scanf("%d",&b);
data[i].member[data[i].pos]=b;
dat[i].teamin[dat[i].pos]=i;
data[i].pos++;
dat[i].pos++;
}
}
printf("%d",-1);
return 0;
}