#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  int ans[n];
  for (int64_t i = (0); i < (n); i++) ans[i] = -1;
  for (int64_t i = (0); i < (m); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (n > 1 && c == 0 && s == 0) {
      cout << -1 << endl;
      return;
    } else if (ans[s] == c)
      continue;
    else if (ans[s] == -1)
      ans[s] = c;
    else {
      cout << -1 << endl;
      return;
    }
  }
  if (n > 1 && ans[0] == -1) ans[1] = 1;
  for (int64_t i = (0); i < (n); i++)
    if (ans[i] == -1) ans[i] = 0;
  for (int64_t i = (0); i < (n); i++) cout << ans[i];
  cout << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
