#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c, s;
  cin >> n >> m;
  if (n == 1 && m == 0) {
    cout << 0;
    return 0;
  }
  if (m == 0) {
    cout << 1;
    for (int i = 1; i < n; i++) cout << 0;
    return 0;
  }
  vector<int> v(n, 10);
  for (int i = 1; i <= m; i++) {
    cin >> c >> s;
    v[c - 1] = min(v[c - 1], s);
  }
  if (v[0] == 10 || v[0] == 0)
    cout << "-1";
  else {
    for (int i = 0; i < n; i++) {
      if (v[i] < 10)
        cout << v[i];
      else
        cout << 0;
    }
  }
  return 0;
}
