#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> num(n, -1);
  int s, c;
  for (long long _ = 0; _ < (long long)(m); _++) {
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (num[s - 1] != -1 && num[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
    num[s - 1] = c;
  }
  if (num[0] == -1)
    cout << 1;
  else
    cout << num[0];
  for (int i = 1; i < n; i++) {
    if (num[i] == -1)
      cout << 0;
    else
      cout << num[i];
  }
  cout << endl;
}
