#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vi(n, 0);
  vector<vector<int> > a(m, vector<int>(2));
  for (int i = 0; i < m; i++) {
    int s, t;
    cin >> s >> t;
    vi[s - 1] = t;
  }
  if (vi[0] != 0) {
    for (int i = 0; i < n; i++) cout << vi[i];
    cout << "\n";
    return 0;
  }
  cout << -1 << endl;
}
