#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> mp;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    if (mp.find(a) != mp.end()) {
      if (mp[a] != b) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      if (a == 1 and b == 0) {
        cout << -1 << endl;
        return 0;
      }
      mp[a] = b;
    }
  }
  vector<long long> ans(n + 1, 0);
  for (auto i = mp.begin(); i != mp.end(); i++) {
    ans[i->first] = i->second;
  }
  if (ans[1] == 0) ans[1] = 1;
  for (long long i = 1; i <= n; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
