#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B>
bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
long long inf = sizeof(long long) == sizeof(long long) ? 2e18 : 1e9 + 10;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  string s(n, ' ');
  while (m--) {
    long long a, b;
    cin >> a >> b;
    if (s[a - 1] != ' ' && s[a - 1] - '0' - b) {
      cout << -1 << endl;
      return 0;
    }
    s[a - 1] = '0' + b;
  }
  if (s[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (s[0] == ' ') s[0] = '1';
  for (long long i = 0; i < n; i++)
    if (s[i] == ' ') s[i] = '0';
  cout << s << endl;
}
