public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);

        StringTokenizer lineTokenizer = new StringTokenizer(scn.nextLine()
                .trim());

        int n = Integer.parseInt(lineTokenizer.nextToken());
        int p = Integer.parseInt(lineTokenizer.nextToken());
        int tc = 1;

        while (n > 0 || p > 0) {
            for (int i = 0; i < n; i++) {
                // Ignores the requirements names
                scn.nextLine();
            }

            int bestCompliance = -1;
            double bestPrice = Double.MAX_VALUE;
            String bestSupplier = null;

            for (int i = 0; i < p; i++) {
                String supplier = scn.nextLine();
                lineTokenizer = new StringTokenizer(scn.nextLine().trim());
                double price = Double.parseDouble(lineTokenizer.nextToken());
                int compliance = Integer.parseInt(lineTokenizer.nextToken());

                if (compliance > bestCompliance
                        || (compliance == bestCompliance && price < bestPrice)) {
                    bestCompliance = compliance;
                    bestPrice = price;
                    bestSupplier = supplier;
                }

                for (int j = 0; j < compliance; j++) {
                    // Ignores the requirements met
                    scn.nextLine();
                }
            }
            if (tc > 1) {
                System.out.println();
            }
            System.out.println("RFP #" + tc++);
            System.out.println(bestSupplier);

            lineTokenizer = new StringTokenizer(scn.nextLine().trim());

            n = Integer.parseInt(lineTokenizer.nextToken());
            p = Integer.parseInt(lineTokenizer.nextToken());
        }
    }