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