#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return 0;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> c(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    c[i] = make_pair(a, b);
  }
  vector<int> x(N, 10);
  if (M != 0) {
    for (int i = 0; i < (int)(M); i++) {
      x[c[i].first - 1] = min(x[c[i].first - 1], c[i].second);
    }
    if (x[0] == 0 || x[0] == 10)
      cout << -1 << endl;
    else {
      for (int i = 0; i < (int)(N); i++) {
        if (x[i] == 10) x[i] = 0;
        cout << x[i];
      }
      cout << endl;
    }
  } else {
    cout << 1;
    for (int i = 0; i < (int)(N - 1); i++) {
      cout << 0;
    }
    cout << endl;
  }
}
