#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int>> st(n);
  for (int i = 0; i < m; i++) {
    int pos, val;
    cin >> pos >> val;
    st[pos - 1].insert(val);
  }
  string s;
  s.resize(n);
  if (st[0].size() == 1 && *st[0].begin() == 0) {
    if (n == 1) {
      cout << 0;
      return 0;
    } else {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (st[i].size() > 1) {
      cout << -1;
      return 0;
    } else if (st[i].size() == 1)
      s[i] = (char)(*st[i].begin() + (int)'0');
    else if (i == 0)
      s[i] = '1';
    else
      s[i] = '0';
  }
  cout << s;
}
