#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double eps = 1e-8;
int to_int(vector<int> &v) {
  int res = 0;
  for (int k : v) res = res * 10 + k;
  return res;
}
int main() {
  int n, m, s, c;
  cin >> n >> m;
  vector<int> di(n, -1);
  for (int i = 0; i < m; ++i) {
    cin >> s >> c;
    if ((di[s - 1] >= 0 && di[s - 1] != c) || (s == 1 && c == 0)) {
      cout << -1 << endl;
      return 0;
    }
    di[s - 1] = c;
  }
  int t = 1;
  for (int i = 0; i < (int)di.size(); ++i) {
    if (di[i] >= 0) t = 0;
    if (di[i] == -1) {
      di[i] = t;
      t = 0;
    }
  }
  cout << to_int(di) << endl;
  return 0;
}
