#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int* ans = (int*)malloc(sizeof(int) * n);
  for (int i = 0; i < n; i++) ans[i] = -1;
  int s, c;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (ans[s - 1] >= 0 && ans[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
    ans[s - 1] = c;
  }
  int sum = 0;
  if (ans[0] == -1) ans[0] = 1;
  for (int i = 1; i < n; i++) {
    if (ans[i] == -1) ans[i] = 0;
  }
  for (int i = 0; i < n; i++) cout << ans[i];
  cout << endl;
  return 0;
}
