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