#include <bits/stdc++.h>
int main() {
  int N = 0, M = 0;
  std::cin >> N >> M;
  std::vector<std::pair<int, int>> P(M);
  std::string ans;
  for (int i = 0; i < N; i++) {
    ans.push_back('A');
  }
  for (int i = 0; i < M; i++) {
    int s, c;
    std::cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      ans = "-1";
      break;
    }
    if (ans[s] != 'A') {
      if (ans[s] != '0' + c) {
        ans = "-1";
        break;
      }
    }
    ans[s] = '0' + c;
  }
  if (ans != "-1") {
    for (int i = 1; i < N; i++) {
      ans[i] = (ans[i] == 'A') ? ('0' + 0) : ans[i];
    }
    ans[0] = (ans[0] == 'A') ? 1 : ans[0];
  }
  std::cout << ans << std::endl;
  return 0;
}
