#include <bits/stdc++.h>
using namespace std;
using LL = long long;
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;
}
const int INF = 1e9;
const LL LLINF = 1e16;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m), d(n, -1);
  for (int i = (0); i < (m); i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (int i = (0); i < (m); i++) {
    if (d[s[i]] != -1 && d[s[i]] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    d[s[i]] = c[i];
  }
  if (n > 1 && d[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = (1); i < (n); i++)
    if (d[i] == -1) d[i] = 0;
  if (d[0] == -1) d[0] = 1;
  for (int i = (0); i < (n); i++) cout << d[i];
  cout << endl;
}
