#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1, 0);
  while (m--) {
    int a, b;
    cin >> a >> b;
    if (a > n or v[a] != 0) {
      cout << -1 << endl;
      return 0;
    } else {
      v[a] = b;
    }
  }
  for (int i = 1; i <= n; i++) cout << v[i];
  cout << endl;
  return 0;
}
