#include <bits/stdc++.h>
using namespace std;
int ans[3];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) ans[i] = -1;
  while (m--) {
    int idx, c;
    cin >> idx >> c;
    if (~ans[--idx]) {
      cout << -1 << '\n';
      return 0;
    }
    ans[idx] = c;
  }
  if (ans[0] == 0) return cout << -1 << '\n', 0;
  if (ans[0] == -1) ans[0] = n == 1 ? 0 : 1;
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1) ans[i] = 0;
    cout << ans[i];
  }
  return 0;
}
