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