#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, M;
  cin >> N >> M;
  bool A = false;
  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;
    data[i][0] = a;
    data[i][1] = b;
    ans[a - 1] = to_string(b)[0];
    if (b == 0) {
      aa[a - 1] = '0';
    }
    for (int d = 0; d < (i + 1); d++) {
      if (data[d][0] == a && data[d][1] != b) {
        A = true;
      }
    }
  }
  if (ans[0] == '0' && aa[0] == '1') {
    ans[0] = '1';
  }
  if (ans[0] == '0' || A) {
    cout << "-1" << endl;
  } else {
    cout << ans << endl;
  }
}
