#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using pii = pair<int, int>;
vector<int> num;
int n, m;
int32_t main() {
  cin >> n >> m;
  num.resize(n);
  fill(((num).begin()), ((num).end()), -1);
  while (m--) {
    int s, c;
    cin >> s >> c;
    if (num[s - 1] != -1 && num[s - 1] != c) {
      cout << -1 << '\n';
      return 0;
    }
    num[s - 1] = c;
  }
  for (int i = 0; i < n; i++) {
    if (num[i] == -1) num[i] = 1;
  }
  if (num[0] == 0 && n > 1) {
    cout << -1 << '\n';
    return 0;
  }
  for (auto it : num) {
    cout << it;
  }
}
