#include <bits/stdc++.h>
using namespace std;
const int MD = (int)1e9 + 7;
void dbg() { cerr << "\n"; }
template <class T, class... T2>
void dbg(const T& fst, const T2&... rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
template <class T, class T2>
void amin(T& a, T2 b) {
  if (a > b) a = b;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int(i) = 0; (i) < (m); (i)++) cin >> s[i] >> c[i];
  vector<int> ans(n, -1);
  for (int(i) = 0; (i) < (m); (i)++) {
    if (n > 1 && s[i] == 1 && c[i] == 0) {
      puts("-1");
      return 0;
    }
    if (ans[s[i] - 1] != -1 && ans[s[i] - 1] != c[i]) {
      puts("-1");
      return 0;
    }
    ans[s[i] - 1] = c[i];
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    if (ans[i] == -1) {
      if (i == 0)
        ans[0] = 1;
      else
        ans[i] = 0;
    }
  }
  for (int(i) = 0; (i) < (n); (i)++) cout << ans[i];
  cout << "\n";
  return 0;
}
