Under construction

Still being built. Things may change

My Lime Orange Tree

Time limit3sMemory limit1024 MB

Summary
Given a tree whose edges hold lime orange counts, decide for each starting root whether the first player wins the piece-moving game.
Level

Medium7 of 10

Topics
Tree, Game theory, Dynamic programming
Solved
No attempts yet

Problem

Mingming, the lime orange tree that Zeze cherishes, is a connected graph with NN vertices and N−1N-1 edges. Edge ii of Mingming has aia_i lime oranges on it. Zeze and Portuga want to play a game on Mingming. On the first turn, Zeze places a piece on vertex rr, the root of Mingming. On each turn, the two players repeat the following steps.

  • Choose any edge adjacent to the vertex where the piece is.
  • Pick at least one lime orange from the chosen edge.
  • Move the piece to the vertex on the other end of the chosen edge.

When a player cannot continue, that is, when no edge adjacent to the piece's vertex has a lime orange left to pick, that player loses the game. For r=1,2,⋯ ,Nr = 1, 2, \cdots, N, write a program that prints "Zeze" if Zeze wins and "Portuga" if Portuga wins, without quotes.

Input

The first line contains NN, the number of vertices of Mingming.

From the second line to line NN, each of the N−1N-1 lines gives xix_i, yiy_i, and aia_i in the form xix_i yiy_i aia_i, where xix_i and yiy_i are the endpoints of edge ii and aia_i is the number of lime oranges on it.

Output

For r=1,2,⋯ ,Nr = 1, 2, \cdots, N, print "Zeze" if Zeze wins or "Portuga" if Portuga wins, without quotes, on NN separate lines.

Constraints

  • 1≤N≤3×1051 \le N \le 3 \times 10^5
  • 1≤ai≤1091 \le a_i \le 10^9

Examples2

  1. Example 1

    Input
    3
    3 1 1
    1 2 1
    
    Expected output
    Zeze
    Portuga
    Portuga
    
  2. Example 2

    Input
    20
    19 2 837009437
    19 3 555623333
    9 6 932422073
    7 11 384958865
    5 7 279037157
    19 5 301909012
    9 14 577327858
    10 15 372601829
    10 16 965167094
    13 10 840904695
    1 13 927245827
    4 1 133242826
    12 4 276397978
    19 12 736742142
    8 17 642702689
    9 8 70136361
    9 18 971340052
    19 9 307149033
    19 20 523797433
    
    Expected output
    Zeze
    Portuga
    Portuga
    Zeze
    Portuga
    Portuga
    Zeze
    Zeze
    Zeze
    Zeze
    Portuga
    Zeze
    Zeze
    Portuga
    Portuga
    Portuga
    Zeze
    Portuga
    Zeze
    Portuga