#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const long long mod = pow(10, 9) + 7;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (A[s] != -1 && A[s] != c) {
      cout << "-1" << endl;
      ;
      exit(0);
    }
    if (s == 0 && c == 0) {
      cout << "-1" << endl;
      ;
      exit(0);
    }
    A[s] = c;
  }
  if (A[0] == -1) A[0] = 1;
  for (int i = 0; i < n; i++) {
    if (A[i] == -1) A[i] = 0;
  }
  string s = "";
  for (int i = 0; i < n; i++) {
    s += to_string(A[i]);
  }
  cout << s << endl;
  ;
}
