241_E. Flights
LiLand is a country, consisting of n cities. The cities are numbered from 1 to n. The country is well known because it has a very strange transportation system. There are many one-way flights that make it possible to travel between the cities, but the flights are arranged in a way that once you leave a city you will never be able to return to that city again.

Previously each flight took exactly one hour, but recently Lily has become the new manager of transportation system and she wants to change the duration of some flights. Specifically, she wants to change the duration of some flights to exactly 2 hours in such a way that all trips from city 1 to city n take the same time regardless of their path.

Your task is to help Lily to change the duration of flights.

Input

First line of the input contains two integer numbers n and m (2 ≤ n ≤ 1000; 1 ≤ m ≤ 5000) specifying the number of cities and the number of flights.

Each of the next m lines contains two integers ai and bi (1 ≤ ai < bi ≤ n) specifying a one-directional flight from city ai to city bi. It is guaranteed that there exists a way to travel from city number 1 to city number n using the given flights. It is guaranteed that there is no sequence of flights that forms a cyclical path and no two flights are between the same pair of cities.

Output

If it is impossible for Lily to do her task, print "No" (without quotes) on the only line of the output. 

Otherwise print "Yes" (without quotes) on the first line of output, then print an integer ansi (1 ≤ ansi ≤ 2) to each of the next m lines being the duration of flights in new transportation system. You should print these numbers in the order that flights are given in the input.

If there are multiple solutions for the input, output any of them.

Examples

Input

3 3
1 2
2 3
1 3


Output

Yes
1
1
2


Input

4 4
1 2
2 3
3 4
1 4


Output

No


Input

5 6
1 2
2 3
3 5
1 4
4 5
1 3


Output

Yes
1
1
1
2
1
2
```python
#Flights
from queue import Queue

def BFS(node ,mk,G):
    q = Queue()
    q.put(node)
    mk[node] = True

    while not q.empty():
        top = q.get()
        for ady in G[top]:
            if not mk[ady]:
                mk[ady] = True
                q.put(ady)


def InitValue(n,m):
    G1 = [[]for _ in range(n+1)]
    G2 = [[]for _ in range(n+1)]
    E = []
    for _ in range(m):
        u,v = map(int,input().split())
        G1[u].append(v)
        G2[v].append(u)
        E.append((u,v))
    return G1,G2,E

def Cleen_Graf(mk1,mk2,n,m,G1,G2):
    E2 = []
    for e in E:
        if mk1[e[0]] and mk2[e[0]] and mk1[e[1]] and mk2[e[1]]:
            E2.append((e[0],e[1],2))
            E2.append((e[1],e[0],-1))
    return E2        


def Bellman_Ford(n,E2):
    dist = [10e12 for _ in range(n+1)]
    dist[1] = 0 
    is_posibol = True
    for _ in range(n):
        for e in E2:
            dist[e[1]] = min(dist[e[1]],dist[e[0]]+e[2])

    for e in E2:
        if dist[e[0]]+e[2] < dist[e[1]]:
            is_posibol = False
                   

    return dist,is_posibol             

if __name__ == '__main__':
    n,m = map(int,input().split())
    G1,G2,E = InitValue(n,m)
    mk1 = [False for _ in range(n+1)]
    mk2 = [False for _ in range(n+1)]
    BFS(1,mk1,G1)
    BFS(n,mk2,G2) 
    E2  = Cleen_Graf(mk1,mk2,n,m,G1,G2)
   
    dist,is_posibol = Bellman_Ford(n,E2)
    if not is_posibol:
        print("No")
    else:
        print("Yes")
        for e in E:
            if mk1[e[0]] and mk2[e[0]] and mk1[e[1]] and mk2[e[1]]:
                print(dist[e[1]]- dist[e[0]])
            else:
                print(1)        
    

    

```