#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M), d = {-1, -1, -1};
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = 0; i < M; i++) {
    if (d[s[i] - 1] == c[i] || d[s[i] - 1] == -1) {
      d[s[i] - 1] = c[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (d[i] == -1) {
      if (i == 0) {
        d[i] = 1;
      } else {
        d[i] = 0;
      }
    }
  }
  if (d[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    cout << d[i];
  }
  cout << endl;
  return 0;
}
