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