#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18;
const int INF = 1e9;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<long long>>;
const long long MOD = 1000000007;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  if (m != 0) {
    vector<int> s(m), c(m);
    for (int i = 0; i < (n); i++) {
      cin >> s[i] >> c[i];
      if (s[i] == 1 && c[i] == 0) {
        cout << "-1" << endl;
        return 0;
      }
      if (ans[s[i] - 1] == -1) {
        ans[s[i] - 1] = c[i];
      } else if (ans[s[i] - 1] == c[i])
        continue;
      else {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1) {
      if (i == 0)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
