﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var numberOfCars = int.Parse(Console.ReadLine());
        List<Car> cars = new List<Car>();
        for (int i = 0; i < numberOfCars; i++)
        {
            var input = Console.ReadLine().Split(' ');
            Car car = new Car(input[0], int.Parse(input[1]), double.Parse(input[2]));
            cars.Add(car);
        }
        var inputCommands = Console.ReadLine();
        while (inputCommands != "End")
        {
            var commandsTokens = inputCommands.Split(' ');
            Car car = cars.Find(c => c.Model == commandsTokens[1]);
            car.Drive(int.Parse(commandsTokens[2]));
            inputCommands = Console.ReadLine();
        }

        foreach (Car car in cars)
        {
            Console.WriteLine(car.ToString());
        }
    }
}
