#P10460. Find the Vulnerable Point of the Defense Line

    ID: 12471 Type: Default 1000ms 256MiB

Find the Vulnerable Point of the Defense Line

Find the Vulnerable Point of the Defense Line

Story: lsp, once ridiculed during math competitions, has finally transformed into the dark hero Lord lsp and now intends to destroy the world. In a fashion reminiscent of a typical anime plot, the elite competitor lqr assembles a super team of math contest stars to stop his devious plans. They arrive before Lord lsp’s dark castle only to encounter a nearly impenetrable defense line.

The defense line is one‐dimensional and consists of (N) groups of armors. Each group is described by three integers (S), (E), and (D) and contributes armors at positions (S,, S+D,, S+2D,, \dots,, S+K,D) where (S+K,D \le E < S+(K+1)D) (i.e. (K) is the maximum integer such that (S+K,D \le E)).

A position is considered vulnerable if the total number of armors at that position is odd. Due to Lord lsp’s ingenious design, there is at most one vulnerable position in the entire defense line. Your task is to help lqr by determining the vulnerable position and reporting the number of armors at that position. If no such vulnerable point exists (i.e. every position has an even count of armors), output "0 0".

inputFormat

The first line contains an integer (N), representing the number of armor groups. This is followed by (N) lines, each containing three integers (S), (E), and (D), where each group places an armor at every position (S, S+D, S+2D, \dots) up to the maximum position not exceeding (E) (i.e. (S+K,D \le E < S+(K+1)D)).

outputFormat

Output two integers separated by a space. If a vulnerable position exists (a position with an odd number of armors), output the position and the total number of armors at that position. If no vulnerable point exists, output "0 0".

sample

3
1 5 2
1 5 2
3 3 1
3 3

</p>