#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  vector<int> s, c;
  cin >> N >> M;
  int tmp;
  for (int i = 0; i < M; i++) {
    cin >> tmp;
    s.push_back(tmp);
    cin >> tmp;
    c.push_back(tmp);
  }
  string ans(3, '-');
  ans.resize(N);
  for (int i = 0; i < M; i++) {
    if (ans.at(s.at(i) - 1) != '-' && ans.at(s.at(i) - 1) != c.at(i) + '0') {
      cout << "-1" << endl;
      return 0;
    }
    ans.at(s.at(i) - 1) = c.at(i) + '0';
  }
  char u = '1';
  for (char &ansi : ans) {
    if (ansi == '-') ansi = u;
    if (u == '1') u = '0';
  }
  cout << ans << endl;
}
