#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using vi = vector<long long>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const long long inf = 1001001001001001;
const int INF = 1001001001;
const int mod = 1000000007;
const double pi = 3.14159265358979323846;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
void decimal(T a) {
  cout << fixed << setprecision(a);
}
template <class T>
void out(T a) {
  cout << a << endl;
}
template <class T>
void outp(T a) {
  cout << '(' << a.first << ',' << a.second << ')' << endl;
}
template <class T>
void outvp(T v) {
  for (long long i = 0; i < (long long)(v.size()); i++) outp(v[i]);
}
template <class T>
void outv(T v) {
  for (long long i = 0; i < (long long)(v.size()); i++) {
    if (i) cout << ' ';
    cout << v[i];
  }
  cout << endl;
}
template <class T>
void outvv(T v) {
  for (long long i = 0; i < (long long)(v.size()); i++) {
    for (long long j = 0; j < (long long)(v[i].size()); j++) {
      if (j) cout << ' ';
      cout << v[i][j];
    }
    cout << endl;
  }
}
void YesNo(bool a) {
  if (a)
    out("Yes");
  else
    out("No");
}
void yesno(bool a) {
  if (a)
    out("yes");
  else
    out("no");
}
void YESNO(bool a) {
  if (a)
    out("YES");
  else
    out("NO");
}
long long GCD(long long a, long long b) {
  long long c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
long long LCM(long long a, long long b) {
  return (a / GCD(a, b)) * (b / GCD(a, b)) * GCD(a, b);
}
long long POW(long long a, long long b) {
  long long c = 1;
  while (b > 0) {
    if (b & 1) {
      c = a * c % mod;
    }
    a = a * a % mod;
    b >>= 1;
  }
  return c;
}
vi calc(long long x) {
  vi res;
  while (x > 0) {
    res.push_back(x % 10);
    x /= 10;
  }
  reverse(res.begin(), res.end());
  return res;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vi keta(n + 1);
  vector<bool> a(n + 1, false);
  for (long long i = 0; i < (long long)(m); i++) {
    int p, q;
    cin >> p >> q;
    if (a[p] == true && q != keta[p]) {
      out(-1);
      return;
    }
    if (p == 1 && q == 0) {
      out(-1);
      return;
    }
    keta[p] = q;
    a[p] = true;
  }
  vi ans(n + 1);
  if (a[1] == false)
    ans[1] = 1;
  else
    ans[1] = keta[1];
  for (long long p = 2; p < (long long)(n + 1); p++) {
    if (a[p] == false)
      ans[p] = 0;
    else
      ans[p] = keta[p];
  }
  for (long long p = 1; p < (long long)(n + 1); p++) cout << ans[p];
  cout << endl;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}
