#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

struct fruit{
    string name;			//название фрукта
    double specific_cost;	//удельная стоимость
    double percentage;		//процентный выход сока
    double amount;			//текущее количество на складе
    double worth(){			//параметр в критерии отбора 
        return (specific_cost * 100)/percentage;
    }
    bool get(){				//логический тип позволяет 
	    return (cin >> name //производить считывание
	    >> specific_cost 	//до конца файла
	    >> percentage
	    >> amount);
	}
};

int main()
{
    double V; int n;		//объем сока и номер посетителя по счёту
    cin >> V >> n;			
    double total_amount = 0;
    /*Заполнение меню - показателя текущего состояния на складе*/
    vector<fruit> menu;
    fruit tmp; 
    while(tmp.get()){
        menu.push_back(tmp);
        total_amount += tmp.amount;
    }
    /*Критерий отбора: отсортировать в порядке уменьшения цены за литр*/
    sort(menu.begin(), menu.end(), [](fruit a, fruit b){return a.worth() < b.worth();});
    /*Составление рецепта коктейля*/
    /*1. Поиск фруктов, доступных на n-м шаге*/
    double used = (n - 1) * V; int starting_position = 0;
    if(total_amount >= n*V &&
    	any_of(menu.begin(), menu.end(), [&](fruit &a) mutable {
            double new_amount = (used -= a.amount);
            if(new_amount >= 0){starting_position++; a.amount = 0;}
            else a.amount = (-1)*new_amount;
            return new_amount < 0;
        })){
        //Заполнение коктейля соком до заданного объёма
        double volume_left = V, price = 0; string recipe;
        /*Добавлять ингредиенты из отсортированного меню, пока возможно*/
        any_of(menu.begin() + starting_position, menu.end(), [&](fruit &a) mutable {
        /*Если ингридиент израсходован*/
            double new_amount = (volume_left -= a.amount);
            if(new_amount >= 0){
            	price += a.specific_cost * a.amount;
                recipe += a.name + ' ' + to_string(a.amount) + '\n';
                a.amount = 0;
            }
       	/*Если коктейль готов*/
            else{
            	a.amount = new_amount + a.amount;
            	price += a.specific_cost * a.amount;
            	recipe += a.name + ' ' + to_string(a.amount) + '\n';
            }
            return (new_amount <= 0);
        });
        cout << recipe << price << endl;
    }
    else cout << "Sorry, we are closed for today." << endl;
    return 0;
}
