#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-9;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
signed main(void) {
  long long n;
  cin >> n;
  string s = "1";
  for (long long i = 0; i < (n - 1); i++) s += "0";
  long long m;
  cin >> m;
  vector<pair<long long, long long> > v(m);
  for (long long i = 0; i < (m); i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  for (long long i = 0; i < (m - 1); i++)
    if (v[i].first == v[i + 1].first && v[i].second != v[i + 1].second) {
      cout << -1 << endl;
      return 0;
    }
  for (long long i = 0; i < (m); i++)
    if (v[i].first == 1 && v[i].second == 0) {
      cout << -1 << endl;
      return 0;
    }
  for (long long i = 0; i < (m); i++) {
    long long ind = v[i].first;
    long long num = v[i].second;
    s[ind - 1] = '0' + num;
  }
  cout << s << endl;
}
