#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << ',' << p.second;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}
void solve() {
  int N;
  int M;
  cin >> N >> M;
  string ans(N, '$');
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ans[s] != '$' && ans[s] != (char)('0' + c)) {
      cout << -1 << endl;
      return;
    }
    ans[s] = (char)('0' + c);
  }
  if (ans[0] == '$') ans[0] = '1';
  for (int i = 1; i < N; i++) {
    if (ans[i] == '$') ans[i] = '0';
  }
  if (N > 1 && ans[0] == '0') {
    cout << -1 << endl;
    return;
  }
  cout << ans << endl;
  return;
}
signed main() {
  fastio();
  solve();
  return 0;
}
