#include <bits/stdc++.h>
using namespace std;
const int MD = 1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2>
void dbg(const T& fst, const T2&... rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> v(n, -1);
  bool ok = true;
  for (int i = 0; i < (m); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (v[s] != -1 && v[s] != c) ok = false;
    if (s == 0 && c == 0) ok = false;
    v[s] = c;
  }
  for (int i = 0; i < (n); i++) {
    if (v[i] == -1) v[i] = i ? 0 : 1;
  }
  if (!ok)
    cout << "-1\n";
  else {
    for (int i = 0; i < (n); i++) cout << v[i];
    cout << "\n";
  }
  return 0;
}
