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