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
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 100010;
const int INF = 2147483600;
int N, M;
int Node[MAXN << 1], Next[MAXN << 1], Root[MAXN + 1], cnt;
bool In[MAXN + 1];
int dis[MAXN + 1];
int U[MAXN + 1], V[MAXN + 1];
bool vis[2][MAXN + 1];
vector<int> vec[2][MAXN + 1];
bool inq[MAXN + 1];
int Cost[MAXN << 1];
int tms[MAXN + 1];
inline void insert(int u, int v, int w) {
  Node[++cnt] = v;
  Next[cnt] = Root[u];
  Cost[cnt] = w;
  Root[u] = cnt;
}
inline void BFS(int n, int k) {
  vis[n][k] = 1;
  queue<int> que;
  que.push(k);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int i = 0, sz = vec[n][u].size(); i < sz; i++) {
      int v = vec[n][u][i];
      if (!vis[n][v]) vis[n][v] = 1, que.push(v);
    }
  }
}
int main() {
  N = read(), M = read();
  for (int i = 1; i <= M; i++) {
    int u = read(), v = read();
    vec[0][u].push_back(v);
    vec[1][v].push_back(u);
    U[i] = u;
    V[i] = v;
  }
  BFS(0, 1);
  BFS(1, N);
  for (int i = 1; i <= N; i++) In[i] = (vis[0][i] && vis[1][i]);
  for (int i = 1; i <= M; i++) {
    int u = U[i], v = V[i];
    if (In[u] && In[v]) {
      insert(u, v, 2);
      insert(v, u, -1);
    }
  }
  queue<int> que;
  for (int i = 1; i <= N; i++) inq[i] = 0, dis[i] = INF;
  dis[1] = 0;
  que.push(1);
  inq[1] = 1;
  while (!que.empty()) {
    int k = que.front();
    que.pop();
    inq[k] = 0;
    if (tms[k] > N) {
      puts("No");
      return 0;
    }
    for (int x = Root[k]; x; x = Next[x]) {
      int v = Node[x];
      if (dis[v] > dis[k] + Cost[x]) {
        dis[v] = dis[k] + Cost[x];
        if (!inq[v]) {
          inq[v] = 1;
          ++tms[v];
          que.push(v);
        }
      }
    }
  }
  puts("Yes");
  for (int i = 1; i <= M; i++)
    if (In[U[i]] && In[V[i]])
      printf("%d\n", dis[V[i]] - dis[U[i]]);
    else
      puts("1");
  return 0;
}
