#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long dp[n + 3];
  for (long long i = 0; i <= n; i++) dp[i] = -1;
  long long ok = 1;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    if (dp[a] == -1)
      dp[a] = b;
    else if (dp[a] != b) {
      ok = 0;
    }
  }
  long long is = 0;
  for (long long i = 1; i <= n; i++) {
    if (is) {
      if (dp[i] == -1) dp[i] = 0;
    } else {
      if (dp[i] == -1) dp[i] = 1;
      is = 1;
    }
  }
  vector<long long> ans;
  for (long long i = n; i >= 1; i--) ans.push_back(dp[i]);
  if (dp[n] == 0) {
    ok = 0;
  }
  if (!ok) {
    cout << -1 << "\n";
    return 0;
  }
  reverse(ans.begin(), ans.end());
  for (long long i = 0; i < n; i++) cout << ans[i];
  cout << "\n";
  return 0;
}
