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