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