#include <bits/stdc++.h>
using namespace std;
void kehsihba() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  long long n, m;
  cin >> n >> m;
  string s(n, '$');
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    if (s[a - 1] == '$') {
      s[a - 1] = (b + '0');
    } else if ((b + '0') != s[a - 1]) {
      cout << -1;
      return;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (i == 0 and s[i] == '$') {
      s[i] = '1';
    } else if (s[i] == '$') {
      s[i] = '0';
    }
  }
  cout << ((s[0] == '0') ? to_string(-1) : s);
}
int32_t main() {
  kehsihba();
  long long t = 1;
  for (long long k = 1; k <= t; k++) {
    solve();
  }
}
