#include <bits/stdc++.h>
using namespace std;
struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;
template <typename A, typename B>
bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename A, typename B>
bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec) stream >> x;
  return stream;
}
void scan() {}
template <class T, class... Args>
void scan(T &a, Args &...rest) {
  cin >> a;
  scan(rest...);
}
using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T>
using vv = vector<vector<T>>;
template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i) stream << ' ' << vec[i];
  }
  return stream;
}
template <typename T>
void print(const vector<T> &t) {
  cout << t << '\n';
}
template <typename T>
void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}
template <typename T>
void print(const T &t) {
  cout << t << ' ';
}
template <typename T, typename... Args>
void print(const T &t, const Args &...rest) {
  print(t);
  print(rest...);
}
template <typename T>
void println(const T &t) {
  cout << t << '\n';
}
template <typename T, typename... Args>
void println(const T &t, const Args &...rest) {
  print(t);
  println(rest...);
}
int main() {
  int n, m;
  scan(n, m);
  vi a(n, -1);
  for (int _iter_112 = 0, _num_112 = (int)(m); _iter_112 < _num_112;
       ++_iter_112) {
    int s, c;
    scan(s, c);
    if (s > n) {
      println(-1);
      return 0;
    }
    --s;
    if (a[s] == -1) {
      a[s] = c;
    } else {
      if (a[s] != c) {
        println(-1);
        return 0;
      }
    }
  }
  if (n > 1) {
    if (a[0] == 0) {
      println(-1);
      return 0;
    } else if (a[0] == -1) {
      a[0] = 1;
    }
  }
  for (int i = (int)(1); i < (int)(n); ++i) {
    if (a[i] == -1) {
      a[i] = 0;
    }
  }
  for (const auto &x : a) {
    cout << x;
  }
  return 0;
}
