#include <bits/stdc++.h>
using namespace std;
using gra = vector<vector<long long>>;
using gram = vector<unordered_map<long long, long long>>;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T dup(T a, T b) {
  return (a + b - 1) / b;
}
template <class T>
T modpow(T x, T p, T m) {
  T a = 1;
  while (p) {
    if (p % 2) a = a * x % m;
    x = x + x % m;
    p /= 2;
  }
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  long long s, c;
  cin >> n >> m;
  long long ok = pow(10, (n - 1));
  string ans = to_string(ok);
  long long fla[n];
  for (long long i = 0; i < n; ++i) {
    fla[i] = 10000000000000000LL;
  }
  for (long long i = 0; i < m; ++i) {
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << (-1) << "\n";
      return 0;
    }
    if (fla[s] == 10000000000000000LL || fla[s] == c) {
      fla[s] = c;
      ans[s] = to_string(c)[0];
    } else {
      cout << (-1) << "\n";
      return 0;
    }
  }
  cout << (ans) << "\n";
}
