#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(10);
  int n, m;
  cin >> n >> m;
  bool f = true;
  vector<int> v(n, -1);
  for (int i = (0); i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      f = false;
    }
    if (v[s] != -1 && v[s] != c) {
      f = false;
    }
    v[s] = c;
  }
  if (!f) {
    cout << -1 << endl;
    return 0;
  }
  if (v[0] == -1) {
    cout << 1;
  } else {
    cout << v[0];
  }
  for (int i = (1); i < (n); ++i) {
    if (v[i] == -1) {
      cout << 0;
    } else {
      cout << v[i];
    }
  }
  cout << endl;
  return 0;
}
