#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (int i = 0; i < ((int)v.size()); ++i) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
template <typename T, size_t S>
void printArray(const T (&array)[S]) {
  for (auto val : array) std::cout << val << ", ";
  std::cout << "\n";
}
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);
  int n, m;
  std::cin >> n >> m;
  string ans(n, '0');
  if (n > 1) ans[0] = '1';
  map<int, int> cnt;
  bool ok = true;
  for (int i = 0; i < (m); ++i) {
    int s, c;
    std::cin >> s >> c;
    ans[s - 1] = '0' + c;
    if (cnt.count(s) != 0 && cnt[s] != c) ok = false;
    cnt[s] = c;
  }
  if (n > 1 && cnt[1] == 0) ok = false;
  if (cnt.size() > n) ok = false;
  std::cout << (ok ? ans : "-1") << "\n";
}
