#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    a[i] = -1;
  }
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (a[x - 1] != -1 && a[x - 1] != y) {
      cout << "-1" << endl;
      return 0;
    }
    a[x - 1] = y;
  }
  if (a[0] == 0 && n != 1) {
    cout << "-1" << endl;
    return 0;
  }
  if (a[0] == -1) {
    a[0] = 1;
  }
  cout << a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] == -1) {
      a[i] = 0;
    }
    cout << a[i];
  }
  return 0;
}
