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