#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x < y ? x : y; }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (int i = 0; i < n; ++i) {
    a[i] = -1;
  }
  pair<long long, long long> b[m];
  map<long long, long long> mp;
  for (int i = 0; i < m; ++i) {
    cin >> b[i].first >> b[i].second;
    b[i].first--;
    if (mp.find(b[i].first) != mp.end()) {
      cout << -1;
      return 0;
    }
    mp[b[i].first] = 1;
  }
  sort(b, b + m);
  if (b[0].first == 0 and b[0].second == 0) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < m; ++i) {
    a[b[i].first] = b[i].second;
  }
  long long t = 1;
  if (a[0] != -1) t = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == -1) {
      if (t) {
        a[i] = 1;
        t = 0;
      } else
        a[i] = 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << a[i];
  }
}
