#include <bits/stdc++.h>
using Int = int;
using namespace std;
template <class T>
T ant(const T &a, const T &b) {
  return a > b ? a : b;
};
template <class T>
T ont(const T &a, const T &b) {
  return a < b ? a : b;
};
template <class T>
T th(T &a, const T &b, T (*f)(const T &, const T &)) {
  a = f(a, b);
}
int main() {
  int a[3] = {-1, -1, -1};
  int n, m;
  cin >> n >> m;
  for (Int i = (0); i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    --s;
    if (a[s] == -1) {
      a[s] = c;
    } else if (a[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (n != 1 && a[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (a[0] == -1) {
    if (n == 1) {
      a[0] = 1;
    } else {
      a[0] = 0;
    }
  }
  if (a[1] == -1) a[1] = 0;
  if (a[2] == -1) a[2] = 0;
  for (Int i = (0); i < (n); ++i) {
    cout << a[i];
  }
  cout << endl;
}
