#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for (int i = 0; i < M; i++) cin >> s[i] >> c[i];
  vector<int> ans(N, -1);
  for (int i = 0; i < M; i++) {
    if (ans[s[i] - 1] == -1) {
      ans[s[i] - 1] = c[i];
    } else {
      if (ans[s[i] - 1] != c[i]) {
        cout << -1;
        return 0;
      }
    }
  }
  if (N == 1) {
    cout << ans[0];
    return 0;
  }
  for (int i = 0; i < M; i++)
    if (s[i] == 1 && c[i] == 0) {
      cout << -1;
      return 0;
    }
  if (ans[0] != -1) {
    cout << ans[0];
  } else
    cout << 1;
  for (int i = 1; i < N; i++) {
    if (ans[i] == -1) {
      cout << 0;
    } else
      cout << ans[i];
  }
  return 0;
}
