#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> s(n, -1);
  bool ok = true;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x;
    if (x > n - 1 || s[x] != -1 && y != s[x]) {
      ok = false;
    }
    s[x] = y;
  }
  if (!ok || s[0] == 0) {
    cout << -1 << '\n';
    return 0;
  }
  if (n == 1) {
    if (s[0] == -1) {
      cout << 0 << '\n';
      return 0;
    } else {
      cout << s[0] << '\n';
      return 0;
    }
  }
  if (s[0] == -1) {
    s[0] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == -1) {
      s[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << s[i];
  }
  cout << '\n';
  return 0;
}
