#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m], c[m];
  for (int i = 0; i < m; ++i) {
    cin >> s[i] >> c[i];
  }
  if (m == 0) {
    if (n == 1) {
      cout << 0 << endl;
      return 0;
    } else if (n == 2) {
      cout << 10 << endl;
      return 0;
    } else {
      cout << 100 << endl;
      return 0;
    }
  }
  string tmp[n];
  for (int i = 0; i < m; ++i) {
    tmp[s[i] - 1] = to_string(c[i]);
  }
  if (tmp[n - 1] == "") {
    cout << -1 << endl;
    return 0;
  }
  if (tmp[0] == "") {
    tmp[0] = to_string(1);
  }
  for (int i = 0; i < n; ++i) {
    if (tmp[i] == "") {
      tmp[i] = to_string(0);
    }
  }
  if (tmp[0] == "0") {
    cout << -1 << endl;
    return 0;
  }
  int ans = atoi(tmp[0].c_str()) * 100 + atoi(tmp[1].c_str()) * 10 +
            atoi(tmp[2].c_str());
  cout << ans << endl;
  return 0;
}
