Under construction

Still being built. Things may change

Platform Depth

Time limit1sMemory limit1024 MB

Summary
For each station i, print the ground height minus the platform height, which is the prefix sum of A minus the prefix sum of B up to i.
Level

Easy1 of 10

Topics
Prefix sum, Implementation
Solved
No attempts yet

Problem

A new subway line under construction in Seoul has N+1N+1 stations numbered 0,1,…,N0, 1, \ldots, N. For each ii (1≤i≤N1 \le i \le N), station i−1i-1 is connected to station ii.

At station 00, the ground surface and the platform are both at height 00 m. For each ii (1≤i≤N1 \le i \le N), moving from station i−1i-1 to station ii raises the ground surface by AiA_i m and the platform by BiB_i m. If AiA_i or BiB_i is negative, that height drops by its absolute value.

The depth of station ii is defined as (ground height at station ii minus platform height at station ii). If the platform is above ground, the depth can be negative.

For each ii (1≤i≤N1 \le i \le N), find the depth of station ii.

Input

The first line contains NN. From the second line onward, the ii-th of the next NN lines contains AiA_i and BiB_i, separated by a space.

Output

Print NN lines. The ii-th line (1≤i≤N1 \le i \le N) contains the depth of station ii.

Constraints

All given numbers are integers.

  • 1≤N≤200 0001 \le N \le 200\,000
  • −1 000≤Ai,Bi≤1 000-1\,000 \le A_i, B_i \le 1\,000 (1≤i≤N1 \le i \le N)

Examples1

  1. Example 1

    Input
    5
    5 3
    2 -2
    -3 2
    -1 -1
    1 10
    
    Expected output
    2
    6
    1
    1
    -8