#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m, x, y;
  cin >> n >> m;
  vector<int> v(n);
  fill(v.begin(), v.end(), -1);
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    --x;
    if (v[x] == -1 || v[x] == y) {
      v[x] = y;
    } else {
      cout << "-1";
      return 0;
    }
  }
  if (n > 1 && v[0] == 0) {
    cout << "-1";
    return 0;
  } else {
    for (int i = 0; i < n; i++) {
      if (v[i] == -1) {
        if (!i) {
          v[i] = 1;
        } else {
          v[i] = 0;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << v[i];
  }
  return 0;
}
