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