#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200;
const int MAX_M = 20;
const int MAX_CN = 1000;

/* typedef */

struct Party {
  string name, cnames[MAX_CN];
  int cn, v, wsn, esn;
  bool won[MAX_CN], elgbl;

  int findcn(string cname) {
    return find(cnames, cnames + cn, cname) - cnames;
  }
};

struct Pprop {
  double f;
  int v, pi;

  bool operator>(const Pprop& p0) const {
    return f > p0.f || (f == p0.f && v > p0.v);
  }
  void print() { printf("Pprop: f=%.6lf, v=%d, pi=%d\n", f, v, pi); }
};

/* global variables */

int n, m;
Party prtys[MAX_M];
Pprop pprps[MAX_M];
map<string,int> pnmap;
int sumv, psns[MAX_M];

/* subroutines */

/* main */

int main() {
  for (bool first = true;; first = false) {
    cin >> n >> m;
    if (n == 0) break;

    pnmap.clear();
    sumv = 0;
    
    for (int i = 0; i < m; i++) {
      Party& prtyi = prtys[i];
      cin >> prtyi.name >> prtyi.cn >> prtyi.v;

      prtyi.wsn = prtyi.esn = 0;
      memset(prtyi.won, false, sizeof(prtyi.won));
      prtyi.elgbl = false;
      pnmap[prtyi.name] = i;
      sumv += prtyi.v;
      
      for (int j = 0; j < prtyi.cn; j++)
	cin >> prtyi.cnames[j];
    }

    for (int i = 0; i < n / 2; i++) {
      int c;
      cin >> c;

      int maxv = 0, maxpi = -1, maxci = -1;
      string maxcname;

      for (int j = 0; j < c; j++) {
	string cname, pname;
	int v;
	cin >> cname >> pname >> v;

	if (maxv < v) {
	  maxv = v;
	  maxpi = pnmap[pname];
	  maxci = prtys[maxpi].findcn(cname);
	  maxcname = cname;
	}
      }

      //printf("c=%d: maxv=%d, maxpi=%d, maxci=%d\n", c, maxv, maxpi, maxci);
      prtys[maxpi].wsn++;
      prtys[maxpi].won[maxci] = true;
      if (maxci >= prtys[maxpi].cn)
	prtys[maxpi].cnames[prtys[maxpi].cn++] = maxcname;
    }

    memset(psns, 0, sizeof(psns));

    int fivepct = sumv * 5 / 100;
    int evsum = 0, eln = 0, asn = 0;

    for (int i = 0; i < m; i++) {
      Party& prtyi = prtys[i];
      if (prtyi.v >= fivepct || prtyi.wsn >= 3) {
	prtyi.elgbl = true;
	evsum += prtyi.v;
	eln++;
      }
    }

    for (int i = 0, j = 0; i < m; i++) {
      Party& prtyi = prtys[i];
      if (prtyi.elgbl) {
	double nst = (double)n * prtyi.v / evsum;
	prtyi.esn = (int)nst;
	asn += prtyi.esn;
	pprps[j].f = nst - prtyi.esn;
	pprps[j].v = prtyi.v;
	pprps[j].pi = i;
	j++;
      }
    }    

    sort(pprps, pprps + eln, greater<Pprop>());

    for (int i = 0; asn < n && i < eln; i++) {
      Pprop& pprpi = pprps[i];
      //pprpi.print();
      prtys[pprpi.pi].esn++;
      asn++;
    }

    vector<string> wcs;

    for (int i = 0; i < m; i++) {
      Party& prtyi = prtys[i];

      for (int j = 0; j < prtyi.cn && prtyi.wsn < prtyi.esn; j++)
	if (! prtyi.won[j]) {
	  prtyi.won[j] = true;
	  prtyi.wsn++;
	}
      for (int j = 0; j < prtyi.cn; j++)
	if (prtyi.won[j]) wcs.push_back(prtyi.cnames[j]);
    }

    sort(wcs.begin(), wcs.end());
    
    if (! first) cout << endl;

    for (int i = 0; i < wcs.size(); i++)
      cout << wcs[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1444