#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int N, M;
  cin >> N >> M;
  int s[M];
  int c[M];
  int ret[N];
  for (int i = 0; i < N; ++i) ret[i] = -1;
  for (int i = 0; i < M; ++i) {
    cin >> s[i];
    cin >> c[i];
  }
  for (int i = 0; i < M; ++i) {
    if (ret[s[i] - 1] != -1 && ret[s[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    if (s[i] == 1 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    ret[s[i] - 1] = c[i];
  }
  for (int i = 0; i < N; ++i) {
    if (ret[i] == -1 && i == 0)
      ret[0] = 1;
    else if (ret[i] == -1)
      ret[i] = 0;
  }
  for (int i = 0; i < N; ++i) cout << ret[i];
  cout << endl;
  return 0;
}
