//* Problem  : 2223 - False Coin
//* Contest  : acm.tju.edu.cn
//* Type     : Solution
//* Date     : 2007.08.21
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

struct weight{
	int n;
	int l[50], r[50];
	char sign;
} a[100];

int w[101], n, k;
char s[1000];

int check_w(int k)
{
	int l = 0, r = 0, i;
	for (i = 0; i < a[k].n; i++)
		l += w[a[k].l[i]];
	for (i = 0; i < a[k].n; i++)
		r += w[a[k].r[i]];
	if (l == r && a[k].sign == '=') return 1;
	if (l > r && a[k].sign == '>') return 1;
	if (l < r && a[k].sign == '<') return 1;
	return 0;
}

int check_all()
{
	for (int i = 0; i < k; i++)
		if (!check_w(i)) return 0;
	return 1;
}

int solve()
{
	int res = 0;
	for (int i = 1; i <= n; i++)
	{
		w[i] = -1;
		if (check_all())
		{
			if (!res || res == i) res = i;
				else return 0;
		}
		w[i] = 1;
		if (check_all())
		{
			if (!res || res == i) res = i;
				else return 0;
		}
		w[i] = 0;
	}
	return res;
}

int main()
{
	int i, j, t, res, tk; char *pos;
	gets(s); sscanf(s, "%d %d", &n, &k);
	for (i = 0; i < k; i++)
	{
		gets(s);
		sscanf(s, "%d", &tk); a[i].n = tk;
		pos = strchr(s, ' ');
		for (j = 0; j < tk; j++)
		{
			sscanf(pos, "%d", &t);
			pos = strchr(pos+1, ' ');
			a[i].l[j] = t;
		}
		for (j = 0; j < tk; j++)
		{
			sscanf(pos, "%d", &t);
			pos = strchr(pos+1, ' ');
			a[i].r[j] = t;
		}
		gets(s); a[i].sign = s[0];
	}
	res = solve();
	printf("%d\n", res);
	return 0;
}