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