#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> d(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (d[s] != -1 && d[s] != c) {
      cout << -1;
      return 0;
    }
    d[s] = c;
  }
  if (d[0] == -1) d[0] = 1;
  for (int i = 1; i < n; i++) {
    if (d[i] == -1) d[i] = 0;
  }
  for (int i : d) cout << i;
  return 0;
}
