#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  unordered_map<int, int> mp;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (mp.count(s) == 1 && mp[s] != c) {
      cout << -1 << "\n";
      return 0;
    }
    mp[s] = c;
  }
  vector<int> dig(n, -1);
  for (int i = 0; i < n; i++) {
    if (mp.count(i) == 1) {
      dig[i] = mp[i];
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == 0 && dig[i] == -1)
      dig[i] = 1;
    else if (dig[i] == -1) {
      dig[i] = 0;
    }
  }
  if (n == 2 && dig[0] == 0 && dig[1] == 0) {
    cout << -1;
    return 0;
  }
  if (n == 3 && dig[0] == 0 && dig[1] == 0 && dig[2] == 0) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cout << dig[i];
  }
}
