void run(){
		Scanner sc = new Scanner(System.in);
		for(boolean h = true;;h=false){
			n = sc.nextInt(); m = sc.nextInt();
			if((n|m)==0)break;
			if(!h)System.out.println();
			Map<String, Integer> ref = new HashMap<String, Integer>();
			String[] s = new String[n];
			for(int i=0;i<n;i++){
				s[i] = sc.next();
				ref.put(s[i], i);
			}
			e = new boolean[m][n];
			for(int i=0;i<m;i++){
				int k = sc.nextInt();
				while(k--!=0)e[i][ref.get(sc.next())] = true;
			}
			u = new boolean[n];
			min = INF;
			f(0, 0);
			if(min==INF)System.out.println("Impossible");
			else {
				System.out.println(min);
				for(int i=0;i<n;i++)if(res[i])System.out.println(s[i]);
			}
		}
	}