#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int s, c;
  cin >> n >> m;
  vector<int> S(n + 1, -1);
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (S[s] != -1 && S[s] != c) {
      cout << "-1" << endl;
      return 0;
    }
    if (S[s] == -1 || S[s] == c) {
      S[s] = c;
    }
    if (n > 1 && s == 1 && c == 0) {
      cout << "-1" << endl;
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (S[i] == -1) {
      if (i == 1)
        S[i] = 1;
      else
        S[i] = 0;
    }
    cout << S[i];
  }
  cout << endl;
  return 0;
}
