#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  while (m--) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ans[s] != -1 && ans[s] != c) {
      cout << -1 << '\n';
      exit(0);
    }
    ans[s] = c;
  }
  if (ans[0] == 0) {
    cout << -1 << '\n';
    exit(0);
  }
  if (ans[0] == -1) ans[0] = 1;
  for (int i = 1; i < n; i++)
    if (ans[i] == -1) ans[i] = 0;
  for (auto &v : ans) cout << v;
  cout << '\n';
}
