#C6523. Floor with Highest Average Motion Distance

    ID: 50293 Type: Default 1000ms 256MiB

Floor with Highest Average Motion Distance

Floor with Highest Average Motion Distance

You are given a building with F floors and S sensors. Each sensor is installed on a certain floor and reports two pieces of data: the number of motion events m and the total distance d (in meters) covered by these motions. For each floor, calculate the average distance per motion event using the formula: \(\text{avg} = \frac{\text{total distance}}{\text{total motions}}\). Your task is to determine the floor with the highest average distance. If multiple floors have the same average, choose the one with the smallest number. If no floor has any motion event, output -1.

inputFormat

Input Format:
The first line of input contains two space-separated integers \(F\) and \(S\), where \(F\) is the number of floors and \(S\) is the number of sensors.
Each of the next \(S\) lines contains three space-separated integers: floor m d, where floor (1 ≤ floor ≤ \(F\)) is the floor number where the sensor is located, m (0 ≤ m ≤ 100) is the number of motion events detected, and d (0 ≤ d ≤ 10000) is the total distance (in meters) covered by those events.
If \(S = 0\), there will be no further input.

outputFormat

Output Format:
Output a single integer representing the floor with the highest average distance per motion event. If no sensor reports any motion events on any floor, output -1.

## sample
3 5
1 5 400
2 10 600
3 10 500
1 4 500
2 6 300
1