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