#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long S[1 << 18], C[1 << 18];
vector<long long> T[9];
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> S[i] >> C[i];
    T[S[i]].push_back(C[i]);
  }
  for (int i = 1; i <= N; i++) {
    sort(T[i].begin(), T[i].end());
    T[i].erase(unique(T[i].begin(), T[i].end()), T[i].end());
  }
  for (int i = 1; i <= N; i++) {
    if (T[i].size() >= 2) {
      cout << "-1" << endl;
      return 0;
    }
  }
  if (T[1].size() == 1 && T[1][0] == 0) {
    cout << "-1" << endl;
    return 0;
  }
  string S = "";
  for (int i = 1; i <= N; i++) {
    if (T[i].size() == 1)
      S += ('0' + T[i][0]);
    else {
      if (i == 1)
        S += '1';
      else
        S += '0';
    }
  }
  cout << S << endl;
  return 0;
}
