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