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