#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct SetupIO {
  SetupIO() {
    cin.tie(nullptr), ios::sync_with_stdio(false),
        cout << fixed << setprecision(13);
  }
} setup_io;
void no() {
  cout << -1 << endl;
  exit(0);
}
signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  for (int(_) = (0), lim_i = (m); (_) < lim_i; (_)++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (a[s] >= 0 && a[s] != c) no();
    a[s] = c;
  }
  if (a[0] == 0) no();
  for (int(i) = (0), lim_i = (n); (i) < lim_i; (i)++) {
    int x = a[i];
    if (x == -1) x = i == 0 ? 1 : 0;
    cout << x;
  }
  cout << endl;
}
