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