#include <bits/stdc++.h>
using namespace std;
int a[3] = {-1, -1, -1};
int c[5] = {0};
int s[5] = {0};
int main() {
  int n, m;
  cin >> n >> m;
  cin.ignore();
  int tmp_s, tmp_c;
  for (int i = 0; i < m; i++) {
    cin >> tmp_s >> tmp_c;
    cin.ignore();
    --tmp_s;
    if ((tmp_s == 0) && (tmp_c == 0) && (n > 1)) {
      cout << -1 << endl;
      return 0;
    }
    if ((a[tmp_s] != tmp_c) && (a[tmp_s] != -1)) {
      cout << -1 << endl;
      return 0;
    }
    a[tmp_s] = tmp_c;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) {
      if (i == 0)
        cout << 1 << flush;
      else
        cout << 0 << flush;
    } else {
      cout << a[i] << flush;
    }
  }
  cout << endl;
  return 0;
}
