#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> a(M, vector<int>(2));
  for (int i = 0; i < M; i++) {
    cin >> a.at(i).at(0) >> a.at(i).at(1);
  }
  vector<int> b(N, 0);
  int record = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < i; j++) {
      if (a.at(j).at(0) == a.at(i).at(0)) {
        if (a.at(j).at(1) = !a.at(i).at(1)) {
          record++;
        }
      }
    }
    b.at(a.at(i).at(0) - 1) = a.at(i).at(1);
  }
  if (b.at(0) != 0 && record == 0) {
    for (int i = 0; i < N; i++) {
      cout << b.at(i);
    }
    cout << endl;
  } else if (record > 0 || b.at(0) == 0) {
    if (N == 1) {
      cout << b.at(0) << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
