#include <bits/stdc++.h>
using namespace std;
int n, m, s, c;
map<int, int> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (ans.find(s) != ans.end()) {
      if (ans[s] != c) {
        cout << -1;
        return 0;
      }
    } else {
      ans[s] = c;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (ans.find(i) == ans.end()) {
      if (i == 1)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  if (n > 1) {
    if (ans[1] == 0) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i];
  }
}
