#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> c(N, -1);
  string ans = "1";
  for (long long i = 0; i < N - 1; i++) ans += "0";
  for (long long i = 0; i < M; i++) {
    int S, C;
    cin >> S >> C;
    if (S == 1 && C == 0) {
      cout << "-1" << endl;
      return 0;
    }
    if (c[S - 1] != -1 && c[S - 1] != C) {
      cout << "-1" << endl;
      return 0;
    }
    ans[S - 1] = '0' + C;
    c[S - 1] = C;
  }
  cout << ans << endl;
}
