#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++) {
    for (int j = 0; j < 2; j++) {
      cin >> a.at(i).at(j);
    }
  }
  sort(a.begin(), a.end());
  bool ans = true;
  if (a.at(0).at(0) == 1 && a.at(0).at(1) == 0) {
    ans = false;
  }
  for (int i = 0; i < M; i++) {
    for (int j = i + 1; j < M; j++) {
      if (a.at(i).at(0) == a.at(j).at(0) && a.at(i).at(1) != a.at(j).at(1)) {
        ans = false;
      }
    }
  }
  if (ans) {
    for (int i = 1; i <= N; i++) {
      bool t = false;
      for (int j = 0; j < M; j++) {
        if (a.at(j).at(0) == i) {
          t = true;
          cout << a.at(j).at(1);
          break;
        }
      }
      if (t) {
        continue;
      } else {
        if (i == 1) {
          cout << 1;
        } else {
          cout << 0;
        }
      }
    }
  } else {
    cout << -1 << endl;
  }
}
