#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<vector<int> > data(M, vector<int>(2));
  string ans = "";
  string aa = "";
  for (int i = 0; i < N; i++) {
    ans += "0";
  }
  for (int i = 0; i < N; i++) {
    aa += "1";
  }
  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    ans[a - 1] = to_string(b)[0];
    if (b == 0) {
      aa[a - 1] = '0';
    }
  }
  for (int i = 0; i < N; i++) {
    if (ans[i] == '0' && aa[i] != '0') {
      ans[i] == '1';
    } else {
      break;
    }
  }
  if (ans[0] == '0') {
    cout << "-1" << endl;
  } else {
    cout << ans << endl;
  }
}
