#include <bits/stdc++.h>
using namespace std;
const char el = '\n';
int main() {
  int n, m;
  cin >> n >> m;
  cin.ignore();
  if (m == 0) {
    cout << "1" << string(n - 1, '0') << el;
    return 0;
  }
  vector<int> pref(n + 1, -1);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    if (pref[s] != -1 && pref[s] != c) {
      cout << -1 << el;
      return 0;
    }
    pref[s] = c;
  }
  if (pref[1] == 0) {
    if (n > 1) {
      cout << -1 << el;
    } else {
      cout << 0 << el;
    }
    return 0;
  }
  int firstspecified = 1;
  while (pref[firstspecified] == -1) {
    ++firstspecified;
  }
  if (firstspecified > 1) {
    cout << "1";
  }
  for (int i = 2; i < firstspecified; ++i) {
    cout << "0";
  }
  for (int i = firstspecified; i <= n; ++i) {
    if (pref[i] != -1) {
      cout << pref[i];
    } else {
      cout << "0";
    }
  }
  cout << el;
}
