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