#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (b < a) a = b;
}
using Mat = vector<vector<ll>>;
using Column = vector<ll>;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> digits(n);
  while (m--) {
    int s, c;
    cin >> s >> c;
    digits[--s] = c;
  }
  if (n > 1 && digits[0] == 0) {
    cout << -1 << "\n";
  } else {
    for (auto &&i : digits) {
      cout << i;
    }
    cout << "\n";
  }
  return 0;
}
