#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  string ans = "";
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    if (s[i] == 1 && c[i] == 0) {
      ans = "-1";
    }
  }
  for (int i = 0; i < m; i++) {
    int k = s[i];
    int v = c[i];
    for (int j = 0; j < m; j++) {
      if (i == j) continue;
      int k2 = s[j];
      int v2 = c[j];
      if (k == k2 && v2 != v) {
        ans = "-1";
        break;
      }
    }
  }
  vector<int> ansv(n, INF);
  if (ans != "-1") {
    for (int i = 0; i < m; i++) {
      int k = s[i] - 1;
      int v = c[i];
      ansv[k] = min(v, ansv[k]);
    }
    for (int i = 0; i < n; i++) {
      if (ansv[i] == INF) {
        ansv[i] = i == 0 ? 1 : 0;
      }
    }
    if (ansv[0] == 0) {
      ansv[0] == 1;
    }
    for (int i = 0; i < n; i++) {
      cout << ansv[i];
    }
  } else {
    cout << -1;
  }
  cout << endl;
  return 0;
}
