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