#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  int ans[n];
  for (int i = 0; i <= n - 1; i++) ans[i] = -1;
  int s[m], c[m];
  for (int i = 0; i <= m - 1; i++) {
    cin >> s[i] >> c[i];
    --s[i];
    if (s[i] >= n) {
      cout << -1 << "\n";
      return 0;
    }
    if (s[i] == 0 && c[i] == 0 && n != 1) {
      cout << -1 << "\n";
      return 0;
    }
    if (ans[s[i]] == -1 || ans[s[i]] == c[i])
      ans[s[i]] = c[i];
    else {
      cout << -1 << "\n";
      return 0;
    }
  }
  for (int i = 0; i <= n - 1; i++) {
    if (ans[i] == -1) {
      if (i != 0)
        ans[i] = 0;
      else
        ans[i] = 1;
    }
  }
  for (int i = 0; i <= n - 1; i++) cout << ans[i];
}
