#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
int main() {
  int N, M;
  cin >> N >> M;
  string t;
  if (N == 1)
    t = "0";
  else
    t = "1";
  for (int i = 1; i < N; i++) t = t + "0";
  map<int, int> r;
  int s, c;
  bool can = true;
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    t[s - 1] = '0' + c;
    if (r.count(s) == 0) {
      r.insert(make_pair(s, c));
    } else {
      if (r[s] != c) can = false;
    }
  }
  if (t[0] == '0') can = false;
  cout << (can ? t : "-1") << '\n';
}
