#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
int main() {
  long long n, m, f = 0;
  cin >> n >> m;
  long long a[n + 1];
  for (long long i = 1; i <= (long long)(n); ++i) a[i] = -1;
  for (long long i = 0; i < (long long)(m); ++i) {
    long long p, q;
    cin >> p >> q;
    if ((a[p] != -1) && (a[p] != q)) {
      f = 1;
    }
    a[p] = q;
  }
  if (a[1] != -1) a[1] = 1;
  for (long long i = 1; i <= (long long)(n); ++i)
    if (a[i] == -1) a[i] = 0;
  if (n != 1) {
    long long j = 1;
    for (j = 1; j <= n; j++) {
      if (a[j] != 0) break;
    }
    if (j != 1) f = 1;
  }
  if (f == 1)
    cout << "-1";
  else
    for (long long i = 1; i <= (long long)(n); ++i) cout << a[i];
}
