#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int INF = 1001001001;
const long long INFL = (1LL << 60);
const double eps = (1e-9);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  for (int i = 0; i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ans[s] != c && ans[s] != -1) {
      puts("-1");
      return 0;
    }
    ans[s] = c;
  }
  if (ans[0] == 0) {
    puts("-1");
    return 0;
  }
  if (ans[0] == -1) ans[0] = 1;
  for (int i = 1; i < n; i++) {
    if (ans[i] == -1) ans[i] = 0;
  }
  for (auto& v : ans) {
    printf("%d", v);
  }
  printf("\n");
  return 0;
}
