#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> res(N, -1);
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (res[s] != -1 && res[s] != c) {
      cout << -1 << '\n';
      return 0;
    }
    res[s] = c;
  }
  if (res[0] == 0) {
    cout << -1 << '\n';
    return 0;
  }
  if (res[0] == -1) {
    res[0] = N == 1 ? 0 : 1;
  }
  for (int i = 0; i < N; i++) {
    if (res[i] == -1) res[i] = 0;
  }
  for (int r : res) {
    cout << r;
  }
  cout << '\n';
  return 0;
}
