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