#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int maxn = 110;
const long long inf = (long long)1e9 + 10;
const long double pi = 3.14159265358979323846264;
const long double eps = 1e-8;
const long long mod = (long long)1e9 + 7;
const long long ns = 97;
const int MAXLOG = 20;
const int N = 45;
random_device rd;
mt19937 SuperRandom(rd());
signed main() {
  ios_base::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  long long n, m;
  cin >> n >> m;
  string s;
  for (long long i = 0; i < n; ++i) s.push_back('#');
  long long f = 0;
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    --a;
    if (a == 0 && b == 0 && n > 1) f = 1;
    if (s[a] == '#' || s[a] == b + '0')
      s[a] = b + '0';
    else
      f = 1;
  }
  if (f)
    cout << -1;
  else {
    for (long long i = 0; i < n; ++i) {
      if (s[i] == '#') {
        if (i == 0)
          s[i] = 1 + '0';
        else
          s[i] = 0 + '0';
      }
    }
    cout << s;
  }
}
