#include <bits/stdc++.h>
using namespace std;
int di[5];
int main() {
  int n, m;
  cin >> n >> m;
  fill(di, di + 5, -1);
  bool sh = false;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (di[s] == -1)
      di[s] = c;
    else
      sh = true;
  }
  if (di[0] == 0 && n > 1) sh = true;
  if (di[0] == -1) di[0] = 1;
  for (int i = 1; i < n; i++) {
    if (di[i] == -1) di[i] = 0;
  }
  if (sh) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < m; i++) cout << di[i];
}
