#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n), c(n);
  for (int i = 0; i < (m); i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  string ans = "1";
  for (int i = 0; i < (n - 1); i++) {
    ans += '0';
  }
  for (int i = 0; i < (m); i++) {
    ans[s[i]] = c[i] + '0';
  }
  for (int i = 0; i < (m); i++) {
    if (ans[s[i]] != c[i] + '0') {
      cout << -1 << endl;
      return 0;
    }
  }
  if (n >= 2 && ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
