#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int strict[4];
  fill(strict, strict + 4, -1);
  for (int i = 0; i < M; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    if (strict[tmp1] != -1 && strict[tmp1] != tmp2) {
      cout << "-1" << endl;
      return 0;
    } else if (tmp1 == 1 && tmp2 == 0) {
      cout << "-1" << endl;
      return 0;
    } else {
      strict[tmp1] = tmp2;
    }
  }
  int ans[4];
  for (int i = 1; i < N + 1; i++) {
    if (strict[i] != -1) {
      ans[i] = strict[i];
    } else {
      if (i == 1)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  for (int i = 1; i < N + 1; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
