#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  bool as = true;
  if (M == 0) {
    as = false;
  }
  if (as) {
    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 && N != 1) {
      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;
    }
  } else {
    cout << 1;
    for (int i = 2; i <= N; i++) {
      cout << 0;
    }
  }
}
