#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int>> vii;
template <typename T>
using vec = vector<T>;
template <class T>
using maxheap = std::priority_queue<T>;
template <class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long double Pi = std::acos(-1.0L);
const long long infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
const int mod = 1000000007;
signed main() {
  int _StartTime_ = clock();
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string s;
  for (int i = 0; i < ((int)(n)); i++) s.push_back('0');
  for (int i = 0; i < ((int)(m)); i++) {
    int p, q;
    cin >> p >> q;
    if (s[p - 1] != '0') {
      cout << -1 << '\n';
      return 0;
    }
    s[p - 1] = char(q + '0');
  }
  if (s[0] == '0' && s.size() != 1) {
    s[0] = '1';
  }
  cout << s << '\n';
}
