#include <bits/stdc++.h>
using namespace std;
bool debug = false;
string yes = "Yes";
string no = "No";
int main() {
  long long n, m;
  cin >> n >> m;
  if (m == 0) {
    if (n == 1) {
      std::cout << 0;
      return 0;
    }
    string ans0 = "1";
    for (long long i = 0; i < (n - 1); ++i) {
      ans0.append("0");
    }
    std::cout << ans0;
    return 0;
  }
  vector<long long> v(n, -1);
  for (long long i = 0; i < (m); ++i) {
    long long s, c;
    cin >> s >> c;
    if ((s == 1 && c == 0) || (v[s - 1] != -1 && v[s - 1] != c)) {
      std::cout << -1;
      return 0;
    }
    v[s - 1] = c;
  }
  string ans;
  for (long long i = 0; i < (n); ++i) {
    if (v[i] == -1) {
      if (i == 0)
        ans += "1";
      else
        ans += "0";
      continue;
    }
    ans.append(to_string(v[i]));
  }
  std::cout << stoi(ans);
  return 0;
}
