#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
int main() {
  cin >> n >> m;
  map<int, int> mp;
  for (int i = 0; i < m; i++) {
    int s, t;
    cin >> s >> t;
    if (t == 1 && s == 0) {
      cout << -1;
      return 0;
    }
    auto itr = mp.find(s);
    if (itr != mp.end()) {
      if (mp[s] != t) {
        cout << -1;
        return 0;
      }
    } else {
      mp[s] = t;
    }
  }
  for (int i = 1; i <= n; i++) {
    auto itr = mp.find(i);
    if (itr == mp.end()) {
      if (i == 1)
        mp[1] = 1;
      else
        mp[i] = 0;
    }
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    cout << itr->second;
  }
}
