#include <bits/stdc++.h>
using namespace std;
int main() {
  int32_t n, m;
  cin >> n >> m;
  vector<uint8_t> ans(3, 0xFF);
  vector<int32_t> s(m), c(m);
  for (uint64_t i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    if (ans[s[i] - 1] == 0xFF) {
      ans[s[i] - 1] = c[i];
    } else if (ans[s[i] - 1] != c[i]) {
      cout << -1;
      return 0;
    }
  }
  if (ans[0] == 0) {
    cout << -1;
    return 0;
  } else if (ans[0] == 0xFF) {
    ans[0] = 1;
  }
  for (uint64_t i = 0; i < n; i++) {
    if (ans[i] == 0xFF) ans[i] = 0;
  }
  for (uint64_t i = 0; i < n; i++) {
    cout << (uint32_t)ans[i];
  }
  return 0;
}
