//* Problem  : 1221 - Euro Cup 2000
//* Contest  : acm.tju.edu.cn
//* Origin   : University of Ulm Local Contest 1999
//* Type     : Solution
//* Date     : 2008.06.06
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 8.0

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

#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <iostream>
using namespace std;
#define int64 long long
#define INF 1000000000
#define EPS 1E-8

#define ALL(a) a.begin(), a.end()
#define PB(a, v) a.push_back(v)
#define MP(a,b) make_pair(a, b)
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
#define FORO(i, obj) for (int i = 0; i < (int)(obj.size); i++)

int n, m;

char name[32][32];
int a[32][32], p[32];
map <string, int> mp;

int lleft[32][2], score[32], rmin[32], rmax[32];

void check()
{
	for (int i = 0; i < n; i++)
	{
		int le = 0, ge = 0;
		for (int j = 0; j < n; j++)
		{
			if (p[i] > p[j]) ge++;
			if (p[i] < p[j]) le++;
		}
		int mmin = le + 1;
		int mmax = n - ge;
		rmin[i] = min(rmin[i], mmin);
		rmax[i] = max(rmax[i], mmax);
	}

}

void backtrack(int d)
{
	if (d == m) check();
	else
	{
		int k1 = lleft[d][0];
		int k2 = lleft[d][1];
		// lose
		p[k2] += 3;
		backtrack(d + 1);
		p[k2] -= 3;
		// tie
		p[k2] += 1;
		p[k1] += 1;
		backtrack(d + 1);
		p[k1] -= 1;
		p[k2] -= 1;
		// win
		p[k1] += 3;
		backtrack(d + 1);
		p[k1] -= 3;
	}
}

int main()
{
#ifdef _DEBUG
	freopen("1166.in", "r", stdin);
#endif
	int it = 0;
	while (scanf("%d", &n) == 1 && n)
	{
		mp.clear();
		memset(a, 0, sizeof(a));
		for (int i = 0; i < n; i++)
		{
			scanf("%s", name[i]);
			mp[string(name[i])] = i;
			p[i] = 0; rmin[i] = 1000; rmax[i] = 0;
		}
		scanf("%d", &m);
		for (int i = 0; i < m; i++)
		{
			char s1[32], s2[32]; int k1, k2, i1, i2, w1, w2;
			scanf("%s %s %d %d", s1, s2, &k1, &k2);
			i1 = mp[string(s1)]; i2 = mp[string(s2)];
			w1 = k1 == k2 ? 1 : k1 > k2 ? 3 : 0;
			w2 = k1 == k2 ? 1 : k1 < k2 ? 3 : 0;
			p[i1] += w1; p[i2] += w2;
			a[i1][i2]++; a[i2][i1]++;
		}
		m = 0;
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++)		
				while (a[i][j] < 2)
				{
					a[i][j]++;
					lleft[m][0] = i;
					lleft[m++][1] = j;
				}
		for (int i = 0; i < m; i++)
		{
//			printf("             %s --  %s\n", name[lleft[i][0]], name[lleft[i][1]]);
		}
		backtrack(0);
		printf("Group #%d\n", ++it);
		for (int i = 0; i < n; i++)
			printf("%s %d-%d\n", name[i], rmin[i], rmax[i]);
		printf("\n");
	}
	return 0;
}
