#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int N, M;
  cin >> N >> M;
  vector<int> a(N, -1);
  bool noFlg = false;
  for (int i = (int)(0); i < (int)(M); ++i) {
    int s, c;
    cin >> s >> c;
    if (noFlg) {
      continue;
    }
    --s;
    if (a[s] == -1) {
      if (s == 0 && N != 1 && c == 0) {
        noFlg = true;
      }
      a[s] = c;
    } else {
      if (a[s] != c) {
        noFlg = true;
      }
    }
  }
  if (noFlg) {
    cout << "No" << endl;
  } else {
    int ans = 0;
    for (int i = 0; i < N; ++i) {
      ans *= 10;
      if (a[i] == -1) {
        if (i == 0) {
          ans += 1;
        }
      } else {
        ans += a[i];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
