#include <bits/stdc++.h>
using namespace std;
bool check(long long i, long long n) {}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n, 0);
  long long s, c;
  for (long long i = 0; i < m; i++) {
    cin >> s >> c;
    s--;
    v[s] = c;
  }
  bool ok = false;
  long long count = 0;
  for (long long i = 0; i < n; i++) {
    if (v[i] != 0) {
      ok = true;
    }
    if (ok == true) {
      count++;
    }
  }
  if (count == 0 && n == 1) {
    cout << "0";
    return 0;
  } else if (count < n) {
    cout << "-1";
    return 0;
  }
  for (auto p : v) {
    cout << p;
  }
}
