#include <bits/stdc++.h>
using namespace std;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
using long long = long long;
using pii = pair<long long, long long>;
using ld = long double;
using pll = pair<long long, long long>;
void precalc() {}
template <class T>
T rnd(T l, T r) {
  using D = uniform_int_distribution<T>;
  static random_device rd;
  static mt19937 gen(rd());
  return D(l, r - 1)(gen);
}
const int MAXN = 90;
long long dt[9][9];
bool cool[8][8];
void solve() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << -1;
      return;
    }
    if (mp.find(s) != mp.end()) {
      if (mp[s] != c) {
        cout << -1;
        return;
      }
    }
    mp[s] = c;
  }
  for (int i = 1; i <= n; ++i) {
    if (mp.find(i) != mp.end()) {
      cout << mp[i];
    } else if (i == 1)
      cout << 1;
    else
      cout << 0;
  }
}
void multisolve() {
  int t;
  cin >> t;
  while (t--) solve();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cout << fixed << setprecision(20);
  precalc();
  solve();
}
