#include <bits/stdc++.h>
using namespace std;
int main() {
  cout << fixed << setprecision(10);
  int N, M;
  cin >> N >> M;
  vector<int> v(N, -1);
  for (int i = 0, i_l = (M); i < i_l; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (N <= s) {
      cout << -1;
      return 0;
    }
    if (s == 0 && c == 0) {
      cout << -1;
      return 0;
    }
    if (v[s] == -1 || v[s] == c) {
      v[s] = c;
    } else {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0, i_l = (N); i < i_l; i++) {
    if (v[i] == -1) {
      if (i == 0) {
        v[i] = 1;
      } else {
        v[i] = 0;
      }
    }
    cout << v[i];
  }
  return 0;
}
