#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  bool zero = false;
  for (int i = 0; i < (int)(m); i++) {
    cin >> p[i].first >> p[i].second;
    if (p[i].first == 1 && p[i].second == 0) {
      if (n != 1) {
        zero = true;
      }
    }
  }
  if (zero) {
    cout << -1 << endl;
    return 0;
  }
  sort((p).begin(), (p).end());
  for (int i = 0; i < (int)(n - 1); i++) {
    if (p[i].first == p[i + 1].first) {
      if (p[i].second != p[i + 1].second) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  string s = "1";
  for (int i = 0; i < (int)(n - 1); i++) {
    s = s + '0';
  }
  for (int i = 0; i < (int)(m); i++) {
    s[p[i].first - 1] = (p[i].second + '0');
  }
  cout << s << endl;
}
