#include <bits/stdc++.h>
using namespace std;
inline void checkmin(int &x, int y) { x = min(x, y); }
inline void checkmax(int &x, int y) { x = max(x, y); }
int n, m;
int s[10], c[10];
map<int, int> mm;
int ans[5];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    if (mm.count(s[i])) {
      if (mm[s[i]] != c[i]) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      mm[s[i]] = c[i];
    }
  }
  int mx = 0;
  for (auto it : mm) {
    mx = max(mx, it.first);
    ans[it.first] = it.second;
    if (it.first == 1 && it.second == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (mx != n) {
    ans[1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
