#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (s > n) {
      cout << "-1" << endl;
      return 0;
    }
    if (ans[s - 1] != -1 && ans[s - 1] != c) {
      cout << "-1" << endl;
      return 0;
    }
    if (s == 1 && c == 0) {
      cout << "-1" << endl;
      return 0;
    }
    ans[s - 1] = c;
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1) {
      ans[i] = i == 0 ? 1 : 0;
    }
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
