#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
using uint = uint32_t;
using ulint = uint64_t;
template <class T>
using vector2d = vector<vector<T>>;
template <class T>
bool UpdateMax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T>
bool UpdateMin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T>
void OutVec(const vector<T> &vec) {
  for (int i = 0; i < vec.size() - 1; ++i) {
    cout << vec[i] << " ";
  }
  cout << vec.back() << endl;
}
template <class T>
void OutVec2d(const vector2d<T> &vec) {
  for (auto v : vec) {
    OutVec(v);
  }
}
int main() {
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    if (s[i] == 1) {
      if (c[i] == 0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  vector<int> result(n + 1, -1);
  for (int i = 0; i < m; i++) {
    if (result[s[i]] == -1) {
      result[s[i]] = c[i];
    } else {
      if (result[s[i]] != c[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (result[1] == -1) {
    result[1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    if (result[i] == -1) {
      result[i] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << result[i];
  }
  cout << endl;
  return 0;
}
