#include <bits/stdc++.h>
using namespace std;
template <class T>
using pql = priority_queue<T, vector<T>>;
template <class T>
using pq = priority_queue<T, vector<T>, greater<T>>;
struct node {
  int64_t to;
  int64_t length;
};
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  return (ret);
}
int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int main(void) {
  int64_t n, m;
  cin >> n >> m;
  vector<int64_t> a(n, 100);
  for (int64_t i = 0; i < m; i++) {
    int64_t s, c;
    cin >> s >> c;
    s--;
    if (a.at(s) != 100 && a.at(s) != c) {
      cout << -1 << endl;
      return 0;
    }
    if (n != 1 && s == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    a.at(s) = c;
  }
  string ans = "";
  for (int64_t i = 0; i < n; i++) {
    if (a.at(i) == 100) {
      if (i == 0) {
        a.at(i) = 1;
      } else {
        a.at(i) = 0;
      }
    }
    ans += (char)(a.at(i) + '0');
  }
  cout << ans << endl;
}
