#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> check(N, -1);
  for (int m = 0; m < M; m++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (check[s] != -1 && check[s] != c) {
      cout << -1 << "\n";
      return 0;
    }
    check[s] = c;
  }
  if (check[0] == 0) {
    cout << -1 << "\n";
    return 0;
  }
  if (check[0] == -1) check[0] = 1;
  for (int n = 1; n < N; n++) {
    if (check[n] == -1) check[n] = 0;
  }
  for (int n = 0; n < N; n++) cout << check[n];
  cout << "\n";
  return 0;
}
