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