#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N, M;
  cin >> N >> M;
  vector<int> digits(N, -1);
  bool isok = 1;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if (digits[s - 1] != -1 && digits[s - 1] != c || s == 1 && c == 0) {
      cout << -1 << endl;
      isok = 0;
      break;
    } else {
      digits[s - 1] = c;
    }
  }
  if (digits[0] == -1) {
    digits[0] = 1;
  }
  for (int i = 1; i < N; i++) {
    if (digits[i] == -1) {
      digits[i] = 0;
    }
  }
  if (isok) {
    for (auto x : digits) {
      cout << x << "";
    }
    cout << endl;
  }
}
