#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    v[i] = -1;
  }
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    if (v[s - 1] == -1) {
      v[s - 1] = c;
    } else {
      if (v[s - 1] != c) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  int i = 0;
  while (i < n && v[i] == -1) {
    v[i] = 1;
    i++;
  }
  while (i < n) {
    if (v[i] == -1) {
      v[i] = 0;
    }
    i++;
  }
  if (v[0] == 0 && n != 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    cout << v[i];
  }
  cout << endl;
  return 0;
}
