#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N;
  cin >> M;
  vector<vector<int>> data(M, vector<int>(2));
  for (int i = 0; i < M; i++) {
    cin >> data.at(i).at(0) >> data.at(i).at(1);
  }
  vector<int> ans(N, -1);
  for (int i = 0; i < M; i++) {
    if (ans.at(data.at(i).at(0)) != -1) {
      if (ans.at(data.at(i).at(0)) != data.at(i).at(1)) {
        cout << -1;
        return 0;
      }
    }
    if (data.at(i).at(0) == 1) {
      if (data.at(i).at(1) == 0) {
        cout << -1;
        return 0;
      }
    }
    ans.at(data.at(i).at(0)) = data.at(i).at(1);
  }
  for (int i = 0; i < N; i++) {
    if (ans.at(i) == -1) ans.at(i) = 0;
  }
  if (ans.at(0) == 0) ans.at(0) = 1;
  for (int i = 0; i < N; i++) {
    cout << ans.at(i);
  }
  return 0;
}
