#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, ans = 0;
  cin >> n >> m;
  vector<long long> a(n, -1), s(m), c(m);
  for (long long i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
    if ((a[s[i]] == -1) || a[s[i]] == c[i]) {
      a[s[i]] = c[i];
    } else {
      ans = -1;
    }
  }
  if (n != 1 && a[0] == 0) {
    ans = -1;
  }
  if (ans == -1) {
    cout << -1;
    return 0;
  }
  if (a[0] == -1) {
    a[0] = 1;
  }
  cout << a[0];
  for (long long i = 1; i < n; i++) {
    if (a[i] == -1) {
      a[i] = 0;
    }
    cout << a[i];
  }
}
