Under construction

Still being built. Things may change

Balance Scale

Interview

Time limit1sMemory limit256 MB

Summary
Given pairwise heavier-than results, count for each object how many others have no implied comparison.
Level

Easy3 of 10

Topics
Graph, DFS
Solved
No attempts yet

Problem

There are NN objects, all of different weights, numbered 1 to NN. For some pairs of objects you already measured on a balance scale which one is heavier, and those results are collected in a table. From that table you can sometimes work out the comparison for a pair you never measured, and sometimes you cannot.

Suppose there are 6 objects and the five measured results are [1]>[2][1]>[2], [2]>[3][2]>[3], [3]>[4][3]>[4], [5]>[4][5]>[4], [6]>[5][6]>[5], where [i][i] means the weight of object ii. From [2]>[3][2]>[3] and [3]>[4][3]>[4] you get [2]>[4][2]>[4]. For objects 2 and 6, the table says nothing about which one is heavier. So object 2 has a known comparison against objects 1, 3, and 4, and an unknown comparison against objects 5 and 6. Object 4 has a known comparison against every other object.

The input never contradicts itself. Suppose [3]>[1][3]>[1] were added to the example above. From [1]>[2][1]>[2] and [2]>[3][2]>[3] you derive [1]>[3][1]>[3], which conflicts with the measured [3]>[1][3]>[1]. Such an input is never given.

Given the number of objects NN and the measured results for some pairs, write a program that prints, for each object, how many objects its comparison result is unknown against.

Input

The first line contains the number of objects NN. The second line contains the number of measured pairs MM. Here 5≤N≤1005 \le N \le 100 and 0≤M≤20000 \le M \le 2000. Each of the next MM lines holds one measured result: two integers separated by a space, where the first object is heavier than the second.

Output

Print the answers on NN lines. Line ii holds the number of objects whose comparison against object ii is unknown.

Examples4

  1. Example 1

    Input
    6
    5
    1 2
    2 3
    3 4
    5 4
    6 5
    
    Expected output
    2
    2
    2
    0
    3
    3
    
  2. Example 2

    Input
    9
    11
    2 1
    3 1
    2 8
    2 9
    7 8
    4 5
    6 7
    6 3
    1 7
    6 2
    1 9
    
    Expected output
    2
    3
    3
    7
    7
    2
    3
    3
    4
    
  3. Example 3

    Input
    5
    0
    
    Expected output
    4
    4
    4
    4
    4
    
  4. Example 4

    Input
    5
    4
    1 2
    2 3
    3 4
    4 5
    
    Expected output
    0
    0
    0
    0
    0