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