#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long s[m], c[m];
  for (long long i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = i + 1; j < m; j++) {
      if (s[i] == s[j]) {
        if (c[i] != c[j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  if (n == 2 || n == 3) {
    for (long long i = 0; i < m; i++) {
      if (s[i] == 1 && c[i] == 0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  long long ans[n];
  memset(ans, -1, sizeof(ans));
  for (long long i = 0; i < m; i++) {
    ans[s[i] - 1] = c[i];
  }
  for (long long i = 0; i < n; i++) {
    if (ans[i] == -1) {
      if (i == 0) {
        ans[i] = 1;
      } else {
        ans[i] = 0;
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
